wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS Python Fundamentals Unit 3 Review

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

Which statement in Python is used to test for multiple conditions of a boolean statement?

a)

else if

b)

elif

c)

elseIf

d)

elsif

2.

What is the problem with the following block of code?

a)

== should be =

b)

missing endif after the last print

c)

missing : after else

d)

choice should be "choice"

3.

Select ALL of the following statements that are TRUE about ALL algorithms:

a)

Algorithms only apply to number calculations

b)

Algorithm instructions must be in a specific order

c)

Algorithms must be written in full sentences

d)

Algorithms should run in a finite amount of time

e)

Algorithms must produce a desired result

4.

Which conditional statement requires all parts to be true in order to become true?

a)

and

b)

or

c)

not

d)

else

5.

For what value of x would the following block of code print "Great"?

a)

1

b)

10

c)

9

d)

0

6.

Write the code to test if the number in the variable num1 is less than or equal to 10.

a)

if (num1 < 10):

b)

if (num1 <= 10):

c)

if (num1 >= 10):

d)

if ("num1" <= 10):

7.

Write the code to test if the number 99 is stored in the variable var1:

a)

if ( var1 == "99"):

b)

if (str(var1) == 99):

c)

if (“var1” == 99):

d)

if (var1 == 99):

8.

Write the code to test if the variables num1 and num2 are NOT the same.

a)

if (num1 < num2 ):

b)

if (num1 != num2 ):

c)

if (equal(num1 == num2)):

d)

if (num1 == num2):

9.

Choose the conditional operator for not equal to:

a)

==

b)

=!

c)

<>

d)

!=

10.

What is output?

a)

1

b)

2

c)

3

d)

4

11.

What is output?

a)

1

b)

2

c)

3

d)

4

12.

Which of the following is NOT true about algorithms? (Select one answer)

a)

must output a string

b)

can produce a result

c)

can be done by a computer

d)

can perform logical operations

13.

Write the code to test if the value of n is greater than or equal to 0.

a)

if (n > 0):

b)

if (n != 0):

c)

if (n <= 0):

d)

if (n >= 0):

14.

Write the code to test if the word “Joe” is stored in the variable name.

a)

if (name = "Joe"):

b)

if ("name" == Joe):

c)

if (name == "Joe"):

d)

if (name != "Joe"):

15.

Which type of statement requires code to be indented?

a)

if statements

b)

input statements

c)

print statements

d)

import statements

16.

Which of the following is a correction for:

if (0 <= x <= 20):

a)

if (0 <= x and <= 20):

b)

if (0 <= x or x <= 20):

c)

if (0 <= x and x <= 20):

d)

if (0 < = x or <= 20):

17.

a = 0

b = 1

Which TWO of the following are true?

a)

a < b and a == b

b)

a > b or a == b

c)

b >= a or a >= b

d)

a < b and a != b

18.

Which of the following is used to compare whether two values are equal?

a)

=

b)

\=

c)

==

d)

=:

19.

Find the mistake in the following code, which checks to see whether the string variable class contains "Math":

if class == "Math"

a)

if should be If

b)

"Math" should be "Math":

c)

== should be =

d)

class should be "class"

20.

Where does the name boolean come from?

a)

named after a 19th century mathematician

b)

named after people who live in the country of Boolea

c)

named because the answer leans to one side or another

d)

named over a bad misspelling of the word binary