Quiz - Module 7
_____ is the process where objects that are no longer needed are deleted.
Garbage collection
What is the value of y after the following code is executed? Note that the question asks for y, not x. x = 10 y = x + 2 x = 12
12
Assigning a value to a floating point variable that is too large for the computer to represent is a condition called _____ .
overflow
15 _____ 3 = 0
%
If text_line = 'one fish two fish', what is the value of text_line[6]?
's'
15 _____ 3 = 5.0
/
What is displayed when the following code is executed? empty_string = '' print(len(empty_string))
0
What is the ending value of z? x = 0.3 z = math.pow(math.ceil(x), 2)
1.0
An item passed to a function is a(n) _____ .
argument
Which floating-point literal correctly represents the scientific notation value: 2.3 x 10^7?
2.3e7
Which of the following is not a valid expression? Assume x and y are integer variables.
2x + 3y
In Python, which of the following literals is shown in valid scientific notation?
3.0004e-12
What is the value of 11 // 2?
5
Which of the following data values is best represented with a floating point variable?
The speed of a snail.
Which statement assigns the string variable airport_code with the value JFK?
airport_code = 'JFK'
The operator *= is called a(n) _____ operator.
compound operator
The built-in Python function that gives an object's identity is:
id()
Objects like integers and strings that can't be modified are called _____ .
immutable
The formula for calculating the amount of interest charged on a loan is: interest = [principal x rate] of interest x time. Which Python statement correctly performs the interest calculation?
interest = (principal * interest) * time
Assume a and b are variables that hold the base and height of a right triangle. The length of the long side (hypotenuse) is calculated as the square root of a^2 + b^2. Which expression calculates the length of the hypotenuse?
math.sqrt(math.pow(a, 2)) + math.pow(b, 2)))
Which expression gives the number of whole minutes that corresponds to some number of seconds?
seconds // 60
According to Python's precedence rules, which of the following operators has the highest precedence?
unary -
A _____ is a named item used to hold a value.
variable
Which expression using parentheses is equivalent to the following expression: x - y * -z / 3
x - ((y * (-z)) / 3)
Which statement is equivalent to the following assignment? x -= 2 + y
x = x - (2 + y)