WorksheetsUnit 3 Test review
Total questions: 11
Worksheet time: 8mins
When do you use an else statement?
When you need to increment a counter.
When you need to convert integers to strings.
When two conditions are mutually exclusive.
When you need to decide if something is false.
Write the code to test if total1 and total2 are the same.
if (total1 = total2)
if (total1 < total2)
if (total1 == total2)
if (total1 != total2)
Select all the lines that have mistakes in the code:
Line 1
Line 2
Line 5
Line 8
Line 11
Which of the following is true about algorithms?
steps for algorithms can be in any order
algorithms must have clear instructions
the code for algorithms can run infinitely
algorithmic code can do only number calculations
Which if the following is equivalent to the code above?
if (count > 25) and (count < 50):
if not(count > 25):
. if not(count < 50):
if (count > 25) or (count < 50):
all of these
none of these
Which operator should you use to check if a is greater than b?
(a)
What is the output?
too hot
too cold
just right
nothing
syntax error
(Extra Credit) Suppose isPrime is a boolean variable, which of the following is the CORRECT AND BEST statement for testing if isPrime is true.
if isPrime = True:
if isPrime == True:
if isPrime:
if not isPrime = False:
if not isPrime == False:
What is printed?
1
2
3
4
What is printed?
1
2
3
4
Which of the following evaluate to 2? (There may be more than one)
12 % 9
int(2.8)
float('2.3')
int('2.0')
