wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CPM2 Quiz Review

Total questions: 25

Worksheet time: 15mins

Name
Class
Date
1.

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)

2.

What is output?

x = -2

y = 3

print (x + y * 2)

(a)  

3.

print (6 % 8)

(a)  

4.

Which line of code outputs the decimal portion of a float stored in the variable x?

a)

print (x / 1000)

b)

print (x - int(x))

c)

print (x)

d)

print (x % 1000)

5.

Three of the following values could be stored as strings. When would you NOT use a string command?

a)

To store a list of colors

b)

To store decimal values

c)

To store a word

d)

To store values NOT used for calculations

6.

What is output?

x = 5

x = x * 3

print (x)

(a)  

7.

Which of the following is NOT a data type in Python?

a)

float

b)

string

c)

decimal

d)

integer

8.

What is output?

x = 9

y = -3

z = 2

print(x + y * z)

a)

7

b)

2

c)

3

d)

18

9.

Which of the following numbers might this code generate: random.randint(1,9)?

a)

10

b)

1

c)

11

d)

0

10.

Which of the following is the Base and Exponent?

3 * 5 + 4 ** 2 - 1

a)

4, 2

b)

2, 5

c)

3, 2

d)

4, 1

11.

What function is used to find the absolute value of a number?

a)

fabs

b)

sqrt

c)

randint

d)

pow

12.

What is output?

print (12 % 5)

a)

0

b)

1

c)

2

d)

5

13.

What is output?

x = 9

y = -2

z = 2

print (x + y * z)

a)

5

b)

9

c)

13

d)

14

14.

You need to find the square root of a value. Which of the following functions would you use?

a)

int

b)

sqrt

c)

fabs

d)

pow

15.

You need to make sure a number the user types in is non-negative. Which of the following functions would you use?

a)

abs

b)

fabs

c)

pos

d)

int

16.

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"))

17.

What is output?

x = 3

y = 5

z = 2

print(y ** z + z)

a)

12

b)

17

c)

25

d)

27

18.

What is output? print (8 % 4)

(a)  

19.

To input a decimal you need the ____________ function.

a)

float

b)

int

c)

str

d)

val

20.

Big Data is measured in

a)

bits

b)

bytes

c)

gigabytes

d)

terabytes

21.

Which of the following would be the best variable name to store the value of your English letter grade?

a)

g

b)

LG

c)

1grade

d)

letter_Grade

22.

It is much more efficient to use computers to perform calculation because they can compute things even humans cannot

a)

True

b)

False

23.

print (min("whom", "carton", "landform", "composite", "apricot", "deposit", "become"))


What is output?

a)

apricot

b)

become

c)

carton

d)

whom

24.

A collection of commands that are given a name:

a)

module

b)

function

c)

choice(sequence)

d)

operator

25.

Storing a value in a variable:

a)

module

b)

assignment

c)

calculation

d)

operator