NEW
Font size
WorksheetsCOMP I77 Module 2 Quiz
Total questions: 25
Worksheet time: 13mins
A is a named item used to hold a value.
constant
number
statement
Which of the following statements has a syntax error? Assume age and years are variables that have already been defined.
age = years - 2
age + 2 = years
age = 17 - 2
age = -15
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
8
10
12
14
Which of the following symbols can be used as part of an identifier?
@
$
&
(underscore)
A is a word that is part of the Python language and can't be used as a variable name.
special token
syntax symbol
stylized word
is the process where objects that are no longer needed are deleted.
Identity recycling
Memory clearing
Object recycling
Objects like integers and strings that can't be modified are called _____.
immutable
mutable
frozen
set
The built-in Python function that gives an object's identity is:
memory()
id()
type()
identity()
What is the name of the data type used for floating point numbers?
float
decimal
non_integer
floating_point
In Python, which of the following literals is shown in valid scientific notation?
3.0004e-12
17.012s14
0.003×10^-5
e12f3.04
Which of the following is not a valid expression? Assume x and y are integer variables.
x / (y * 7)
y / x * 2
2x + 3y
(x - 3*y)
Which expression using parentheses is equivalent to the following expression: x - y * -z / 3
(x - y) * ((-z) / 3)
x - ((y * (-z)) / 3)
x - (y * ((-z) / 3))
(x - (y * (-z))) / 3
The operator *= is called a(n) ____ operator.
A. double
B. compound
C. increment
D. multiple assignment
Which statement is equivalent to the following assignment? x -= 2 + y
x = 2 + y - x
x = -(2 + y)
x = x - (2 + y)
x = x - 2 + y
15 3 = 5.0
%
^
//
What is the value of 11 // 2?
5
6
0
3
Which statement makes the code in the math module available?
use math
allow math
import math
include math
Which print statement displays the value of a variable called argv in a module called sys?
print(argv in sys)
print(sys.argv)
print(sys_argv)
print(module sys var argv)
What is the value of the __name__ built-in variable in a module that is executed as a script by the programmer?
__main__
__direct__
__module__
__executed__
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.square_root(a * a + b * b)
math.sqrt(math.pow(a * a), math.pow(b * b))
math.sqrt(math.pow(a, 2)) + math.pow(b, 2)))
math.pow(math.sqrt(a), 2) + math.pow(math.sqrt(b), 2)
The special two-item character sequence that represents special characters like \n is known as a(n) _____.
backslash code
escape sequence
unicode spec
literal character
What does print("one\two\three") display?
one\\two\\\three
one\two\\three
one twothree
one\\\\two\\\\\\three
Which print statement would display the letter 'A'? (Note that the code point for the letter 'A' is 65.)
print(chr(65))
print(ord(65))
print(unicode(65))
print(code_point(65))
Which print statement would display 'C:\Users\Mika\grades.txt' (without the single quotes)?
printr('C:\Users\Mika\grades.txt')
print(r'C:\'Users\'Mika\'grades.txt')
print(r'C:\Users\Mika\grades.txt')
print(r'C:\\Users\\Mika\\grades.txt')
Which print statement would display: I won't quit!
print('I won\\'t quit!')
print('I won' t quit!')
print('I won\'\t quit!')
print('I won\'t quit!')
