Font size
WorksheetsTest 3 Review
Total questions: 25
Worksheet time: 26mins
What is an if-then statement used for in a program?
To allow programs to make decisions.
To allow programs to repeat
To allow programs to do nothing
To allow programs to perform a number calculation.
What is the output?
TRUE
FALSE
TRUEFALSE
FALSETRUE
It should be rewritten as:
if (90 < = x <= 100):
if (90 < = x and x <= 100):
Nothing, the if statement is correct
When do you use an else statement?
Else statement has no purpose.
When you need something to happen every time.
When you need something to happen when the if condition is true.
To tell what will happen when an if-statement is false.
Write the code to test if num1 and num2 are NOT the same.
if (num1 != num2 )
if (num1 == num2 )
if (num1 = num2)
if (num1 < num2 )
The symbol != means
Both conditions must be true
One or both conditions must be true.
Equal
Not equal to.
The symbol < means
Less than
Greater than
Equal
Not equal to
The symbol <= means
Less than
Greater than
Less than equal
Not equal to
The symbol == means
Less than
Greater than
Equal
Not equal to
The symbol and means
Both conditions must be true.
One or both conditions must be true.
Equal
Not equal to
The symbol or means
Both conditions must be true.
One or both conditions must be true.
Equal
Not equal to
The symbol not means
Both conditions must be true.
One or both conditions must be true.
Equal
Not equal to
What is the output?
1
2
3
4
What is the output?
1
2
3
4
How would you write the code: "If the variable letter holds h."
if ( letter == "h"):
if ( letter == h):
if ( letter = "h"):
if ( letter != "h"):
How would you write the code: "If value is not less than 13.6"
if (value > 13.6):
if (value <= 13.6):
if (value >= "13.6"):
if (value >= 13.6):
Which of the following is NOT true about algorithms?
have clear instructions
stop in a finite amount of time
do number calculations
have an order
The following code could be rewritten using:
if (x > 12):
if ( x < 34):
not
or
and
none of the others
Which of the following are true about algorithms? (You may select more than one)
must output a string
produce a result
can be done by a computer
can perform logical operations
What are the two reasons we analyze algorithms?
Ease of coding
Predict performance
Make decisions about what algorithm to use
Sorting Data
Select all the mistakes (there may be more than one) in the following:
The = should be ==
elseif should be elif
there is no end if
The else should have a :
When should you use an ELIF statement?
To repeat sections of code
To make a follow-up True/ False decision
To count user actions
To get user input
What best defines an algorithm?
Code that does an action
A set of precise steps used to perform a task, typically on a computer
Steps used to complete a goal
Using IF and ELSE statements in order to gather input and print outputs
For if statements to work in Python you must ____________.
add an else to them
make decisions about them
indent their code block
use them with input commands
Which of the following is used to show not equals?
==
!=
!!
=!
