Font size
WorksheetsCPM2 Quiz Review
Total questions: 25
Worksheet time: 15mins
To create a random number between –20 and 20 you would use:
print (random.random(-20))
print (random.randint(-20, 20))
print (random.randint( 20) -20)
print (random.random() -20)
What is output?
x = -2
y = 3
print (x + y * 2)
(a)
print (6 % 8)
(a)
Which line of code outputs the decimal portion of a float stored in the variable x?
print (x / 1000)
print (x - int(x))
print (x)
print (x % 1000)
Three of the following values could be stored as strings. When would you NOT use a string command?
To store a list of colors
To store decimal values
To store a word
To store values NOT used for calculations
What is output?
x = 5
x = x * 3
print (x)
(a)
Which of the following is NOT a data type in Python?
float
string
decimal
integer
What is output?
x = 9
y = -3
z = 2
print(x + y * z)
7
2
3
18
Which of the following numbers might this code generate: random.randint(1,9)?
10
1
11
0
Which of the following is the Base and Exponent?
3 * 5 + 4 ** 2 - 1
4, 2
2, 5
3, 2
4, 1
What function is used to find the absolute value of a number?
fabs
sqrt
randint
pow
What is output?
print (12 % 5)
0
1
2
5
What is output?
x = 9
y = -2
z = 2
print (x + y * z)
5
9
13
14
You need to find the square root of a value. Which of the following functions would you use?
int
sqrt
fabs
pow
You need to make sure a number the user types in is non-negative. Which of the following functions would you use?
abs
fabs
pos
int
Which line of code is necessary for random numbers to work in Python?
import random
import integer
x = randomint
. x = int(input ("Enter a number"))
What is output?
x = 3
y = 5
z = 2
print(y ** z + z)
12
17
25
27
What is output? print (8 % 4)
(a)
To input a decimal you need the ____________ function.
float
int
str
val
Big Data is measured in
bits
bytes
gigabytes
terabytes
Which of the following would be the best variable name to store the value of your English letter grade?
g
LG
1grade
letter_Grade
It is much more efficient to use computers to perform calculation because they can compute things even humans cannot
True
False
print (min("whom", "carton", "landform", "composite", "apricot", "deposit", "become"))
What is output?
apricot
become
carton
whom
A collection of commands that are given a name:
module
function
choice(sequence)
operator
Storing a value in a variable:
module
assignment
calculation
operator
