Font size
WorksheetsCS Python Fundamentals Unit 3 Review
Total questions: 20
Worksheet time: 11mins
Which statement in Python is used to test for multiple conditions of a boolean statement?
else if
elif
elseIf
elsif
What is the problem with the following block of code?
== should be =
missing endif after the last print
missing : after else
choice should be "choice"
Select ALL of the following statements that are TRUE about ALL algorithms:
Algorithms only apply to number calculations
Algorithm instructions must be in a specific order
Algorithms must be written in full sentences
Algorithms should run in a finite amount of time
Algorithms must produce a desired result
Which conditional statement requires all parts to be true in order to become true?
and
or
not
else
For what value of x would the following block of code print "Great"?
1
10
9
0
Write the code to test if the number in the variable num1 is less than or equal to 10.
if (num1 < 10):
if (num1 <= 10):
if (num1 >= 10):
if ("num1" <= 10):
Write the code to test if the number 99 is stored in the variable var1:
if ( var1 == "99"):
if (str(var1) == 99):
if (“var1” == 99):
if (var1 == 99):
Write the code to test if the variables num1 and num2 are NOT the same.
if (num1 < num2 ):
if (num1 != num2 ):
if (equal(num1 == num2)):
if (num1 == num2):
Choose the conditional operator for not equal to:
==
=!
<>
!=
What is output?
1
2
3
4
What is output?
1
2
3
4
Which of the following is NOT true about algorithms? (Select one answer)
must output a string
can produce a result
can be done by a computer
can perform logical operations
Write the code to test if the value of n is greater than or equal to 0.
if (n > 0):
if (n != 0):
if (n <= 0):
if (n >= 0):
Write the code to test if the word “Joe” is stored in the variable name.
if (name = "Joe"):
if ("name" == Joe):
if (name == "Joe"):
if (name != "Joe"):
Which type of statement requires code to be indented?
if statements
input statements
print statements
import statements
Which of the following is a correction for:
if (0 <= x <= 20):
if (0 <= x and <= 20):
if (0 <= x or x <= 20):
if (0 <= x and x <= 20):
if (0 < = x or <= 20):
a = 0
b = 1
Which TWO of the following are true?
a < b and a == b
a > b or a == b
b >= a or a >= b
a < b and a != b
Which of the following is used to compare whether two values are equal?
=
\=
==
=:
Find the mistake in the following code, which checks to see whether the string variable class contains "Math":
if class == "Math"
if should be If
"Math" should be "Math":
== should be =
class should be "class"
Where does the name boolean come from?
named after a 19th century mathematician
named after people who live in the country of Boolea
named because the answer leans to one side or another
named over a bad misspelling of the word binary
