Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Practice for 2nd Python Quiz Comp Prog B

Total questions: 12

Worksheet time: 10mins

Name
Class
Date
1.

What is 11//4?

a)

2.75

b)

2

c)

3

d)

11

2.

What is 11%4?

a)

2.75

b)

2

c)

3

d)

11

3.

This program is intended to display a random answer from the list answers. Which would be the best replacement for < missing code >?

a)

randint(1,2)

b)

randint(0,2)

c)

randint(0,1)

d)

randint(2,2)

4.

What is printed by the following program?

a)

first

b)

second

c)

third

d)

nothing

5.

A student programmer is writing a program to calculate the number of taxis that a group of p people would need. Taxis can carry up to a maximum of 5 people. Which would be the best replacement for < condition >?

a)

p%5 > 0

b)

p%5 == 0

c)

p//5 > 0

d)

p//5 == 0

6.

The following program is to print each element of the list nums. Which would be the best replacement for < missing code >?

a)

for n in nums

b)

for nums in n

c)

while n < nums

d)

while nums < n

7.

Which of the following is NOT a possible output of this program?

a)

0

b)

1

c)

2

d)

3

8.

What is the output of this program?

a)

5

b)

6

c)

15

d)

21

9.

How many variables are in this program?

a)

0

b)

1

c)

2

d)

3

10.

What is the output of this program?

a)

1 2 3

b)

1 1 3

c)

2 2 3

d)

2 1 3

11.

What is 1 % 9999999?

a)

0

b)

1

c)

9999999

d)

undefined

12.

Which of the following would be a correct function definition for the isSum10 function which given two integer values return True if their sum is 10 and False otherwise?

a)

A only

b)

B only

c)

C only

d)

A B & C