Font size
WorksheetsUnit 5 Coding Review
Total questions: 76
Worksheet time: 57mins
What do Booleans represent in Python?
Numbers
Lists
Strings
True or False values
What will the expression 'print(10 > 9)' return?
False
True
9
10
How can you print a message based on a condition in Python?
Using a while loop
Using a for loop
Using an if...else statement
Using a switch case
What is the output of 'print(10 == 9)'?
False
Error
True
None
What is the result of the following code?
print(10 != 9)
True
False
What does < mean?
Greater than
Less than
Equal to
Greater than and equal to
What does > mean?
Less than
Greater than
Equal to
Greater than and equal to
Is 6 >= 7
True
False
Not sure
Is 4 > 5
True
False
Not sure
Is 4 < 5
True
False
Not sure
Is 1.005 >= 1.000
True
False
Not Sure
age=21
not(age > 10)
True
False
age=9
(age > 10) or (age < 20)
True
False
age=21
(age > 10) or (age < 20)
True
False
age=21
(age > 10) and (age < 20)
True
False
Which booleans have a value of True?
12 - 3 == 9
30 <= 25
17 != 11 + 6
15 / 5 == 3.0
Which of these evaluates as true if x = 100 and y = 50
x < 200 and y < 100
x == 100 and y > 50
x >90 and y < 100
x == 100 and y != 50
What is the output to the python code?
X = 5
Y = 5
print(X == Y)
The "If" Statement is an example of a _________________
Correctional Statement
Competitive Statement
Conditional Statement
Inquisitive Statement
How many "if" statements can a single program have?
<10
<20
<30
As many as is needed
Which of these can be paired with an "if" statement to represent other outcomes of a scenario?
or
else
but
sheboygan
What are booleans?
Pieces of code that only run "under certain conditions":
conditional statements
control flow statments
syntax
variables
What is elif in Python?
eliminate if
else if
A person's name
False
What part of an if statement should be indented?
All of it
The statements within it
the first line
the lines within the brackets
Expresses a true/false statement
Runs a true/false statement based on data entered
Which of the following are NOT true about logical operators
allow you to connect and modify boolean expressions
and, or, not
are not important
Result in True/False
__________ are used to make logical associations between boolean values.
Operands
Operators
logical operators
mathematical operators
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
True
False
"is weekend"
"is_saturday || is_sunday"
What symbol represents the and operator in Python?
AND
and
&
&&
What symbol represents the or operator in Python?
OR
OAR
or
| |
__________ are used to make comparisons between values.
mathematical operators
comparison operators
logical operators
operations
What is the proper way to compare if two values are equal in boolean expression?
=
==
equals
is
How can you compare if it two things are not equal?
not equals
NOT EQUALS
=!
!=
Friday = False
if Friday:
print "Jeans day!"
else:
print "Dress code"
What will happen when this program is run?
Syntax error
One will be displayed
Zero will be displayed
One then Zero will be displayed
What will this code print?
access denied
access granted
error
password
What will happen when this program is run?
Syntax error
Big will be displayed
Small will be displayed
300 will be displayed
What is the output?
more than 7
more than 23
spam
7
Pieces of code that only run "under certain conditions":
conditional statements
control flow statments
syntax
variables
Data type that can only be true or false
int
string
boolean
float
The value 1.73 rounded to one decimal place using the “rounding up” strategy is…
1.7
1.8
1.73
Which of the following is not a logical operator in Python?
A. and
B. or
C. not
D. because
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. if alarm and tired: sleep
B. if not alarm or tired: sleep
C. if not alarm and tired: sleep
D. if not alarm and not tired: sleep
Which of the following programs will run but will not print anything?
A. x = True if x: print("hi")
B. if False: print("hi")
C. x = False if x: print("hi") else: print("hello")
D. if True:
Which of the following evaluates to the variable x rounded to two decimal places?
round(x, 2)
round(2, x)
round(x), 2
round(2), x
Which of the following values is rounded to 3 decimal places?
2.3
3.000
3.0001
3
What does this Python expression evaluate to? 100 != 100
True
False
“True”
“False”
Which of the following is not a comparison operator?
<=
!=
?
>
How many possible values are there for a boolean variable?
1
2
3
There is an infinite number of possibilities.
Why should you use round when you compare two numbers that have type float?
If you don’t, Python will only compare the whole part and discard the decimal part.
You don’t have to, but it’s good style. All of the comparisons will still work out the same way.
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.
You should always use round when you compare two numbers, even if they are of type int.
What is the result of the following expression: `not True`?
True
False
None
0
Which of the following is not a logical operator in Python?
`and`
`or`
`not`
`==`
What will be the output of the following code?
x = 3.14159
print(round(x, 2))
3.14
3.15
3.141
3.142
What data type is 12.0?
string
int
float
boolean
Which of the following are NOT true about logical operators
allow you to connect and modify boolean expressions
and, or, not
are not important
Result in True/False
Else if (elif) is used in which situation?
If the previous conditions were not true
You can use if statement to replace elif
else is enough for now
Any situation
What will this output?
Mine is too!
An error
MINE IS TOO!
Nothing
What will this program output?
:(
":("
Error
nothing
What will be the output of this code?
x = 13
y = 14
if x==y:
print("Hello")
else:
print("Hi")
Hello
Hi
13
14
In Python, what are if-statements used for?
Looping
Indexing
Decision Making
Testing
belowFreezing = temperature < 32
What is belowFreezing?
variable that is an integer
variable that is an boolean
variable that is a string
boolean expression
arithmetic expression
"Wear a snow jacket!" is printed when temperature is
30
31
32
33
What is printed?
BRRR its cold out there!
Do you want to make a snowman?
Nothing
What is printed?
BRRR its cold out there!
Do you want to make a snowman?
Nothing
What is the purpose of the "else" statement in an "if-else" block?
To execute a block of code if the condition is true
To execute a block of code if the condition is false
To repeat a block of code multiple times
To skip the current iteration of a loop
Which character must be at the end of the line for if?
:
;
.
{
