wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Unit 2 Quiz 2

Total questions: 12

Worksheet time: 7mins

Name
Class
Date
1.

Consider the following code:

x = 3

y = 5

z = 2

print(y ** z + z)

What is output?

a)

12

b)

17

c)

25

d)

27

2.

Consider the following code:

x = 3

y = - 4

z = 1

print( x + y * y )

a)

2

b)

-2

c)

19

d)

5

3.

What output is produced by:

x = 19.29428347

x = x * 100

num = int(x)

print(num)

a)

19.2943

b)

19

c)

1929

d)

19.29

4.

Which line of code is necessary for random numbers to work in Python?

a)

import random

b)

import integer

c)

x = randomint

d)

x = int(input("Enter a number"))

5.

Which of the following is NOT a Python Command?

a)

int

b)

str

c)

input

d)

dec

6.

What is output?

print(7 % 4)

a)

0

b)

1

c)

2

d)

3

e)

4

7.

What is output?

print(8 % 4)

a)

0

b)

1

c)

2

d)

3

e)

4

8.

Consider the following code:

c = 100

c = c + 1

c = c + 1

print(c)

(a)  

9.

To input an integer you need the __________ function.

a)

float

b)

int

c)

str

d)

val

10.

To create a random number between -20 and 20 you would use:

a)

print (random.random(-20))

b)

print (random.randint(-20,20))

c)

print (random.randint(20) -20)

d)

print(random.random() -20)

11.

Which term means - storing a value in a variable?

a)

Assignment

b)

Exponent

c)

Operator

d)

Variable

12.

What variable name is the BEST to hold the number of pounds of fish?

a)

x

b)

1Fish

c)

1A

d)

pounds