Font size
WorksheetsPython Unit 2 Quiz 2
Total questions: 12
Worksheet time: 7mins
Consider the following code:
x = 3
y = 5
z = 2
print(y ** z + z)
What is output?
12
17
25
27
Consider the following code:
x = 3
y = - 4
z = 1
print( x + y * y )
2
-2
19
5
What output is produced by:
x = 19.29428347
x = x * 100
num = int(x)
print(num)
19.2943
19
1929
19.29
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"))
Which of the following is NOT a Python Command?
int
str
input
dec
What is output?
print(7 % 4)
0
1
2
3
4
What is output?
print(8 % 4)
0
1
2
3
4
Consider the following code:
c = 100
c = c + 1
c = c + 1
print(c)
(a)
To input an integer you need the __________ function.
float
int
str
val
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)
Which term means - storing a value in a variable?
Assignment
Exponent
Operator
Variable
What variable name is the BEST to hold the number of pounds of fish?
x
1Fish
1A
pounds
