WorksheetsTechSmart Unit 2 Test
Total questions: 25
Worksheet time: 14mins
What is the name of the data type that can only be True or False?
integer
string
y/n
boolean
Which of the following is a boolean expression?
x + 1
x = 100
x == y
12 * 5
How many times does the following loop repeat?
never
1 time
90 times
infinitely
In the following code, what print statements will be printed?
print("x and y are equal")
print("x is less than 100")
print("y is less than 100")
print("Something else.")
In the following code, select all the print statement that will be printed.
print("x and y are equal")
print("x is less than 100")
print ("y is less than 100")
print("Something else.")
In the following code, select all print statement that will be printed.
print("x and y are equal")
print("x is less than 100")
print("Something else.")
print("y is less than 100")
How many times will the following code print the statement "Print me"?
(a)
Will the following boolean expression return True or False?
True
False
Will the following boolean expression return True or False?
True
False
Will the following boolean expression return True or False?
True
False
Will the following boolean expression return True or False?
True
False
What's wrong with the following loop?
It won't loop even once
Input can't be inside a loop
Input gets a string, so x < 100 is not a valid condition
The == operator is used to store input, not =
In the following code, select the conditional that includes elif-clauses.
Lines 4 & 5
Lines 7 & 8
Lines 10 & 11
Lines 13 & 14
Lines 16 & 17
Select the conditions in the following code.
x == y
x < 100
x > 100
else
What is the name of the library used in this code?
(a)
What type of error prevents your code from running?
Syntax error
Runtime error
Logic error
You can always run code, even when you have errors
In the code below, select the line that will cause a runtime error.
Line 2
Line 3
Line 4
Line 5
What symbol is used to separate multiple arguments within a function call?
) (parenthesis)
. (dot)
, (comma)
# (number sign)
What is the highest number of times this loop could repeat?
(a)
What is one use for the dot operator in Python?
Separate the arguments in a function call
Designate the end of a code statement
Call a function from a library
Replace a space in a variable name
Change one symbol in this code so it loops 20 times instead of infinitely. (It should still print multiples of 5.)
-= to !=
-= to +=
-= to ==
-= to %
What two arguments does the random.randint function require?
random and randint
A minimum and a maximum
( and )
, and .
What strategy can be used to find logic errors?
Look at the error message
Insert print statements
Either error messages or print statements
Logic errors cannot be found by a person
What strategy can be used to find runtime errors?
Look at the error message
Insert print statements
Either error messages or print statements
Runtime errors cannot be found by a person
What strategy can be used to find syntax errors?
Look at the error message
Insert print statements
Either error messages or print statements
Syntax errors cannot be found by a person
