ACIT 1516 - Midterm Review

0.0(0)
studied byStudied by 27 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/115

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

116 Terms

1
New cards

Text within quotes ““ is known as a?

string

2
New cards

Can strings contain letters, numbers and symbols

Yes

3
New cards

What is the syntax for a newline command?

\n

4
New cards

What is an escape sequence?

Starts with a backslash ex: \\, \t and \n

5
New cards

what does an “=” sign indicate?

Assignment operator

6
New cards

What is an object within parentheses known as?

Arguments

7
New cards

What does the argument end=”” do?

2+ statements in the same string can be put on different lines

8
New cards

What does the float operator do?

represents numbers with decimal components

9
New cards

operations such as +=, -=, /= and *= are used for?

Incrementing

10
New cards

When you perform a math operation with 2 integer values, what data type will your answer be in?

Integer

11
New cards

When you perform a math operation with one integer value and one float value, what data type will your answer be in?

float

12
New cards

Dividing integers gives you which data type as a quotient?

float

13
New cards

What does the % do?

Modulus gives you the remainder after a number is divided

14
New cards

What is // for?

Floor division. Number of times reciprocal can go into divisor

15
New cards

is random.randrange(x,y) inclusive of both x and y?

Only inclusive of x

16
New cards

is random.randint(x,y) inclusive of both x and y?

Yes

17
New cards

How many pathways does 1 bit have?

2

18
New cards

How many pathways does 1 byte (8 bits) have?

256

19
New cards

What are the 3 defining properties of each object in python?

value, type, identification

20
New cards

How do you write 2×10^6 in python?

2.0e6

21
New cards

How do you represent place value after the decimal?

:.xf with x representing the number of digits after the decimal

22
New cards

How do you represent place value before a decimal?

:0xf with x representing the number of digits before the decimal

23
New cards

What is the order of precedence for basic math operators? ( /, *, +, - , etc)

() - parentheses → ** - exponents → - urnary → % * / → + and -

24
New cards

If two operators of equal precedence are included in an equation, (ex: / and *), how do we determine which goes first

Operation is done from left to right

25
New cards

What does the r before a string indicate?

Raw string. All commands such as \n are void and will be displayed as regular text in the string

26
New cards

What is concatenation?

Adding to the very end of an existing list

27
New cards

What is an element?

A value within a list

28
New cards

What is an index?

An integer that specifies the position of an element within a list

29
New cards

What is a list?

mutable ordered collection of items 

30
New cards

What does the .pop() function do?

removes the element at specified index

31
New cards

What does the .remove() function do?

removes the first element whose value matches the value specified in your argument

32
New cards

what does the .append() function do?

Adds to end of a list

33
New cards

What does the min() function do?

Finds the smallest value in a list

34
New cards

What does the max() function do?

Finds the largest value in a list

35
New cards

what does the sum() function do?

Finds the sum of all numbers in a list

36
New cards

What is a tuple?

immutable storage of data

37
New cards

What does a dictionary do?

Associates keys with values

38
New cards

What is a key in a dictionary?

term that is located within dictionary

39
New cards

What is a value in a dictionary?

a value that is associated with a key

40
New cards

What type of brackets do tuples use?

Curly brackets { }

41
New cards

What type of brackets do dictionaries use?

parentheses ( )

42
New cards

What type of brackets do lists use?

Square brackets [ ]

43
New cards

What is the command used to delete something in a dictionary?

del dict[k]

44
New cards

What is the order of precedence between basic math operations, greater/less than, not and & or operators?

() → * / % → + - → < <= > >= == != → not → and → or

45
New cards

The built-in Python function that gives an object's identity is:

id()

46
New cards

Assigning a value to a floating point variable that is too large for the computer to represent is a condition called _____ .

overflow

47
New cards

A language is called _____ when upper case letters in identifiers are considered different from lower case letters.

case sensitive

48
New cards

_____ is the process where objects that are no longer needed are deleted.

Garbage collection

49
New cards

Which floating-point literal correctly represents the scientific notation value: 2.3 x 10^7?

2.3e7

50
New cards

What is the value of the name built-in variable in a module that is executed as a script by the programmer?

__main__

51
New cards

The operator *= is called a(n) _____ operator.

compound

52
New cards

Which statement changes the value associated with key "Lemon" to 0.75 in the dictionary fruits_dict?

fruits_dict["Lemon"] = 0.75

53
New cards

Which expression calculates the average of first_num and second_num?

first_num = input('Enter the first number: ')
second_num = input('Enter the second number: ')

(float(first_num) + float(second_num)) / 2

54
New cards

Which of the following expressions causes an implicit conversion between types? Assume variable x is an integer, t is a float, and name is a string.

7.5 + (x / 2)

55
New cards

What is the value of: 1 + int(3.5) / 2?

2.5

56
New cards

Which of the following statements produces an error? Assume string_1 = 'abc' and string_2 = '123'.

string_1[1] = 'B'

57
New cards

Given x = 1, y = 2, and z = 3, how is the expression evaluated? In the choices, items in parentheses are evaluated first.

(x 5) or (y 2) and (z == 5)

False OR (True AND False) --> False OR False --> False

58
New cards

Grover Cleveland served as president of the United States from 1885 to 1889 and from 1893 to 1897. Which expression correctly detects this range?

(1885 <= x <= 1889) or (1893 <= x <= 1897)

59
New cards

Given year is positive, which expressions for XXX, YYY, and ZZZ will output the correct range? Choices are in the form XXX / YYY / ZZZ.

if XXX: Output "1-100"

elif YYY: Output "101-200"

elif ZZZ: Output "201-300"

else: Output "Other"

year < 101 / year < 201 / year < 301

60
New cards

For what values of integer x will Branch 3 execute?

if x < 10 : Branch 1

elif x > 9: Branch 2

else: Branch 3

For no values (never executes)

61
New cards

Which operator is evaluated last in an expression?

or

62
New cards

What is the final value of z?

grades = { 'A': 90, 'B': 80, 'C': 70, 'D': 60 }
my_grade = 70
if my_grade not in grades:
    z = 1
else:
    z = 2
if 'F' in grades:
    z = z + 10
else:
    z = z + 20

21

63
New cards

What is wrong with the badly formatted code?

x = input()
if x == 'a':
print('first')
print('second')

The first print() statement must be indented.

64
New cards

What sequence will range(9) give you?

all non-negative integers less than 9 (0-8)

65
New cards

What will the range(X, Y) give you?

All integers >=X and <Y

66
New cards

What will the range(X,Y,Z) give you?

All integers >=X to <Y and incrementing by Z

67
New cards

For the following loop, how many times will the inner loop body execute?
for i in range(2):
for j in range(3): # Inner loop body

6

68
New cards

What is a function with no return statement called?

Void function

69
New cards

What is the word for a function’s behavior of adding together different data types
ex: (‘x’ * 5)

polymorphism

70
New cards

What is Modular Development

dividing a program into separate modules that can be integrated into a single program

71
New cards

def ‘calc_pizza_area():’ is an example of a

function definition

72
New cards

What is a parameter?

function input specified in a function definition

73
New cards

What is an argument?

value provided to a parameter

74
New cards

What are local variables?

variables defined within a function definition

75
New cards

What is a global variable?

A variable defined outside of a function

76
New cards

What data types are immutable?

Strings, integers

77
New cards

What is a keyword argument?

allows argument to map parameters by nam

78
New cards

What does the parameter have in this function definition?
def print_date(day, month, year, style=0):

Default parameter

79
New cards

How can you create a docstring in your code?

by using “““ or ‘‘‘ before and after your text

80
New cards

What is a docstring

a multi-line comment

81
New cards

What does the help() function do?

providing all the docstrings for the intended function, providing a programmer with information on how to call the function

82
New cards

What is the alignment character I use to make my text centre-aligned?

^

83
New cards

What is the alignment character I use to make my text left-aligned?

<

84
New cards

What is the alignment character I use to make my text right-aligned?

>

85
New cards
f"{'Bob':_>5}"

What does this code output?

__Bob

86
New cards

using the following string, how can you replace ‘one’ with ‘four’?

phrase = “I want one banana”

phrase.replace(one, four)

87
New cards

How can you use the replace method to replace all instances of a word in a string?

var.replace(old,new) with old being the word you want replaced and new being the word you replaced it with

88
New cards

How can you replace only x occurrences of a word in a string?

.replace(old,new,x)

89
New cards

What method finds the position of where a character is located in a string?

.find(x)

90
New cards

How can find the position of where a character is located in a string if I want to start from the reverse of a string?

.rfind(x)

91
New cards

What method is used to find the number of times x occurs in a string?

.count(x)

92
New cards

Which method returns True if all characters in the string are lowercase or uppercase letters, or the numbers 0-9?

.isalnum()

93
New cards

Which method returns True if all characters are the numbers 0-9?

.isdigit()

94
New cards

Which method returns True if all cased characters are lowercase letters?

.islower()

95
New cards

Which method eturns True if all cased characters are uppercase letters?

.isupper()

96
New cards

Which method returns True if all characters are whitespace?

.isspace()

97
New cards

Which method returns true if the string starts with x

.startswith(x)

98
New cards

Which method returns a copy of the string with only the first letter capitalized?

.capitalize()

99
New cards

Which method returns a copy of a string with all characters lowercased?

.lower()

100
New cards

Which method returns a copy of the string with all characters in uppercase?

.upper()