wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit 5 Coding Review

Total questions: 76

Worksheet time: 57mins

Name
Class
Date
1.

What do Booleans represent in Python?

a)

Numbers

b)

Lists

c)

Strings

d)

True or False values

2.

What will the expression 'print(10 > 9)' return?

a)

False

b)

True

c)

9

d)

10

3.

How can you print a message based on a condition in Python?

a)

Using a while loop

b)

Using a for loop

c)

Using an if...else statement

d)

Using a switch case

4.

What is the output of 'print(10 == 9)'?

a)

False

b)

Error

c)

True

d)

None

5.

What is the result of the following code?

print(10 != 9)

a)

True

b)

False

6.
How do we make sure that IF statements are indented correctly?
a)
Don't need to
b)
Use the Tab key
c)
Use the Shift Key
d)
Use the Enter Key
7.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)
holds whole numbers
c)
holds a decimal point in a number
d)
hold either true or false
8.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
9.
This operator means that one value is not equal to another value
a)
==
b)
<=
c)
>=
d)
!=
10.

What does < mean?

a)

Greater than

b)

Less than

c)

Equal to

d)

Greater than and equal to

11.

What does > mean?

a)

Less than

b)

Greater than

c)

Equal to

d)

Greater than and equal to

12.

Is 6 >= 7

a)

True

b)

False

c)

Not sure

13.

Is 4 > 5

a)

True

b)

False

c)

Not sure

14.

Is 4 < 5

a)

True

b)

False

c)

Not sure

15.

Is 1.005 >= 1.000

a)

True

b)

False

c)

Not Sure

16.

age=21

not(age > 10)

a)

True

b)

False

17.

age=9

(age > 10) or (age < 20)

a)

True

b)

False

18.

age=21

(age > 10) or (age < 20)

a)

True

b)

False

19.

age=21

(age > 10) and (age < 20)

a)

True

b)

False

20.

Which booleans have a value of True?

a)

12 - 3 == 9

b)

30 <= 25

c)

17 != 11 + 6

d)

15 / 5 == 3.0

21.

Which of these evaluates as true if x = 100 and y = 50

a)

x < 200 and y < 100

b)

x == 100 and y > 50

c)

x >90 and y < 100

d)

x == 100 and y != 50

22.

What is the output to the python code?
X = 5

Y = 5

print(X == Y)

a)
Error
b)
True
c)
None
d)
False
23.
How many choices are possible when using a single if-else statement?
a)
1
b)
2
c)
3
d)
4
24.

The "If" Statement is an example of a _________________

a)

Correctional Statement

b)

Competitive Statement

c)

Conditional Statement

d)

Inquisitive Statement

25.

How many "if" statements can a single program have?

a)

<10

b)

<20

c)

<30

d)

As many as is needed

26.

Which of these can be paired with an "if" statement to represent other outcomes of a scenario?

a)

or

b)

else

c)

but

d)

sheboygan

27.

What are booleans?

a)
Numbers between 1 and 10
b)
Strings of text
c)
Arrays of values
d)
True or false values
28.

Pieces of code that only run "under certain conditions":

a)

conditional statements

b)

control flow statments

c)

syntax

d)

variables

29.

What is elif in Python?

a)

eliminate if

b)

else if

c)

A person's name

d)

False

30.

What part of an if statement should be indented?

a)

All of it

b)

The statements within it

c)

the first line

d)

the lines within the brackets

31.
A boolean;
a)

Expresses a true/false statement

b)
can contain letters, numbers, spaces, and symbols.
c)
takes in an input, does something with it, and then returns an output.
d)

Runs a true/false statement based on data entered

32.

Which of the following are NOT true about logical operators

a)

allow you to connect and modify boolean expressions

b)

and, or, not

c)

are not important

d)

Result in True/False

33.

__________ are used to make logical associations between boolean values.

a)

Operands

b)

Operators

c)

logical operators

d)

mathematical operators

34.

After the following code runs, what is the value of is_weekend? (assume correct syntax)

is_saturday = True

is_sunday = False

is_weekend = is_saturday or is_sunday

a)

True

b)

False

c)

"is weekend"

d)

"is_saturday || is_sunday"

35.

What symbol represents the and operator in Python?

a)

AND

b)

and

c)

&

d)

&&

36.

What symbol represents the or operator in Python?

a)

OR

b)

OAR

c)

or

d)

| |

37.

__________ are used to make comparisons between values.

a)

mathematical operators

b)

comparison operators

c)

logical operators

d)

operations

38.

What is the proper way to compare if two values are equal in boolean expression?

a)

=

b)

==

c)

equals

d)

is

39.

How can you compare if it two things are not equal?

a)

not equals

b)

NOT EQUALS

c)

=!

d)

!=

40.
The result of this program:
Friday = False
if Friday:

    print "Jeans day!"
else:
    print "Dress code"
a)
Jeans Day
b)
Jeans day
c)
Dress code
d)
Dress Code
41.

What will happen when this program is run?

a)

Syntax error

b)

One will be displayed

c)

Zero will be displayed

d)

One then Zero will be displayed

42.

What will this code print?

a)

access denied

b)

access granted

c)

error

d)

password

43.

What will happen when this program is run?

a)

Syntax error

b)

Big will be displayed

c)

Small will be displayed

d)

300 will be displayed

44.
The second part of if, that is executed when the condition is false
a)
if
b)
else
c)
for
d)
input
45.
What will the lines of code print?
a)
A
b)
B C
c)
A B C
d)
A C
46.
What will the following lines of code print?
a)
A
b)
B C
c)
A C
d)
Nothing, it will return an error.
47.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

48.

Pieces of code that only run "under certain conditions":

a)

conditional statements

b)

control flow statments

c)

syntax

d)

variables

49.

Data type that can only be true or false

a)

int

b)

string

c)

boolean

d)

float

50.

The value 1.73 rounded to one decimal place using the “rounding up” strategy is…

a)

1.7

b)

1.8

c)

1.73

51.

Which of the following is not a logical operator in Python?

a)

A. and

b)

B. or

c)

C. not

d)

D. because

52.

Which of the following conditions tell me to sleep if my alarm did not go off (alarm = False) and I’m tired (tired = True)?

a)

A. if alarm and tired: sleep

b)

B. if not alarm or tired: sleep

c)

C. if not alarm and tired: sleep

d)

D. if not alarm and not tired: sleep

53.

Which of the following programs will run but will not print anything?

a)

A. x = True if x: print("hi")

b)

B. if False: print("hi")

c)

C. x = False if x: print("hi") else: print("hello")

d)

D. if True:

54.

Which of the following evaluates to the variable x rounded to two decimal places?

a)

round(x, 2)

b)

round(2, x)

c)

round(x), 2

d)

round(2), x

55.

Which of the following values is rounded to 3 decimal places?

a)

2.3

b)

3.000

c)

3.0001

d)

3

56.

What does this Python expression evaluate to? 100 != 100

a)

True

b)

False

c)

“True”

d)

“False”

57.

Which of the following is not a comparison operator?

a)

<=

b)

!=

c)

?

d)

>

58.

How many possible values are there for a boolean variable?

a)

1

b)

2

c)

3

d)

There is an infinite number of possibilities.

59.

Why should you use round when you compare two numbers that have type float?

a)

If you don’t, Python will only compare the whole part and discard the decimal part.

b)

You don’t have to, but it’s good style. All of the comparisons will still work out the same way.

c)

Sometimes numbers can be rounded in unexpected ways based on how Python computes them. Therefore, it is best to use round in order to make sure both numbers are rounded the same way.

d)

You should always use round when you compare two numbers, even if they are of type int.

60.

What is the result of the following expression: `not True`?

a)

True

b)

False

c)

None

d)

0

61.

Which of the following is not a logical operator in Python?

a)

`and`

b)

`or`

c)

`not`

d)

`==`

62.

What will be the output of the following code?

x = 3.14159

print(round(x, 2))

a)

3.14

b)

3.15

c)

3.141

d)

3.142

63.

What data type is 12.0?

a)

string

b)

int

c)

float

d)

boolean

64.

Which of the following are NOT true about logical operators

a)

allow you to connect and modify boolean expressions

b)

and, or, not

c)

are not important

d)

Result in True/False

65.

Else if (elif) is used in which situation?

a)

If the previous conditions were not true

b)

You can use if statement to replace elif

c)

else is enough for now

d)

Any situation

66.

What will this output?

a)

Mine is too!

b)

An error

c)

MINE IS TOO!

d)

Nothing

67.

What will this program output?

a)

:(

b)

":("

c)

Error

d)

nothing

68.

What will be the output of this code?
x = 13

y = 14

if x==y:

print("Hello")

else:

print("Hi")

a)

Hello

b)

Hi

c)

13

d)

14

69.

In Python, what are if-statements used for?

a)

Looping

b)

Indexing

c)

Decision Making

d)

Testing

70.

belowFreezing = temperature < 32

What is belowFreezing?

a)

variable that is an integer

b)

variable that is an boolean

c)

variable that is a string

d)

boolean expression

e)

arithmetic expression

71.

"Wear a snow jacket!" is printed when temperature is

a)

30

b)

31

c)

32

d)

33

72.

What is printed?

a)

BRRR its cold out there!

b)

Do you want to make a snowman?

c)

Nothing

73.

What is printed?

a)

BRRR its cold out there!

b)

Do you want to make a snowman?

c)

Nothing

74.

What is the purpose of the "else" statement in an "if-else" block?

  

a)

To execute a block of code if the condition is true

b)

To execute a block of code if the condition is false

c)

To repeat a block of code multiple times

d)

To skip the current iteration of a loop

75.

Which character must be at the end of the line for if?

a)

:

b)

;

c)

.

d)

{

76.
Which is the correct syntax?
a)
has_dog = true
b)
has_dog = True
c)
has_dog = Treu
d)
HAS_DOG = tRue