Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Conditionals Review

Total questions: 31

Worksheet time: 17mins

Name
Class
Date
1.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

2.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

3.

What is the output?

a)

more than 7

more than 23

b)

more than 23

c)

True

d)

more than 7

e)

True

True

4.

What is the output?

a)

250.0

b)

200.0

c)

300.0

d)

350.0

5.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

6.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

7.

What is the output?

a)

True

b)

NIL

c)

True

NIL

d)

True

NIL

NIL

8.

What is the output?

a)

level 3

b)

level 3

level 1

c)

level 3

level 1

NIL

d)

level 3

level 2

level 1

NIL

9.

What is the output?

a)

40

b)

15.0

c)

30

d)

25.0

10.

What will print to the screen when the following program is run?

a)

5

b)

True

c)

<class ‘int’>

d)

<class ‘bool’>

11.

What will be the output of this program?

a)

0

b)

5

c)

True

d)

Nothing will print

12.

What is the result of this code?

a)

Issue Driver's License

b)

Almost eligible for Driver's License

c)

No requirements met.

d)

none of these

13.
a)
You can buy some chocloate
b)
You are rich!
c)
Get a job!
d)
You almost have enough
Get a job!
14.
a)
You can buy some chocolate
b)
You are rich
c)
You almost have enough
d)
Get a job!
15.

Data type that can only be true or false

a)

int

b)

string

c)

boolean

d)

float

16.

Which one of the following shows correct syntax ?

a)

if answer == "Yes"

b)

if answer == "Yes":

c)

if answer = "Yes":

17.

If you want to test more than one condition (chained condition), what do you use after if statement?

a)

elif

b)

else

c)

ifif

d)

else if

18.

Which character must be at the end of an IF statement?

a)

:

b)

;

c)

.

d)

{

19.

What is the output?

a)

nothing will be printed

b)

HelloBob

c)

Hello Bob

I don't know you

d)

Hello Bob

20.

What will be the output of the following code?

a)

11.50

b)

12

c)

11.6

d)

11.5

e)

Error. Invalid syntax

21.

How many stars will be printed?

a)

Error, char is not defined.

b)

11

c)

12

d)

0

22.

What will the output be?

a)

2

b)

11

c)

0

d)

Nothing. syntax error

23.

Choose the 3 steps in the anatomy of the accumulator pattern.

a)

initializing the accumulator variable

b)

updating the accumulator variable

c)

testing the accumulator variable

d)

iterating over the items in a sequence

24.

Select all the strings that are less than "December"

a)

"december"

b)

"Decagon"

c)

"D Nice"

d)

"123December"

25.

dogs = [12, 10, 12, 8, 7, 6, 9, 10, 12, 11] contains the ages of the dogs at doggie daycare. Which code correctly finds the age of the youngest dog?

a)
b)
c)
d)
26.

x: 5 < 10

y: 6 > 7

What is the truth value for: x and y

a)

True

b)

False

27.

x: 5 < 10

y: 6 > 7

What is the truth value for: (not x) or y

a)

True

b)

False

28.

If you want to solve "x and (x or not y)" using a truth table, you would need columns for x, y and the statement you want to solve. What other columns would you need?

a)

not x

b)

not y

c)

x and y

d)

x or not y

29.

If you have a list of grades and you want to iterate over the list to find out which grade is the highest. How should you initialize your accumulator variable?

a)

highest_grade = 0

b)

highest_grade = 1

c)

highest_grade = grades[-1]

d)

highest_grade = grades[0]

30.

Which of these statements will make sure (.0045 / 100) and (.0045) will compare to be equal in an if statement?

a)

if round (0.0045 / 100, 5) == round(0.000045, 5):

b)

if round (0.0045 / 100, 5) = round(0.0045, 5):

c)

if (0.0045 / 100, round) == (0.0045, round):

d)

if (0.0045 / 100).round() == 0.0045.round():

31.

If x contains the number 0.00456, how would I round x to 4 decimal places?

a)

x.round(4)

b)

round(x, 4)

c)

round.x(4)

d)

round(4, x)