Worksheets[AP CSP] Programming with Conditionals [If, Elif, Else]
Total questions: 35
Worksheet time: 2hrs 59mins
Failure
What will be printed to the screen?
Failure
Part of the way there!
Success
Nothing
==)!=)<=)== = john = 5 .
if john > 6: .
. print("John is getting ice cream")
else: .
. print("John is getting apple juice")
print("John is getting grapes") .
John is getting grapes
John is getting grapes
Which of the following scenarios is best suited for using chained else-if statements?
Printing "YES" or "NO" in a program
Sorting an LIST of Integers.
Determining the grade based on a score.
Calculating the factorial of a number.
You are building a weather application. Which feature would require the use of chained else-if statements?
Recommending an outfit based on the weather conditions.
Displaying the current temperature.
Showing the name of the city.
Displaying the time of sunset.
You are creating a simple video game. In which scenario would chained else-if statements be useful?
Managing player statuses (e.g., "Healthy", "Injured", "Poisoned").
Drawing game characters.
Updating the game clock.
Loading game assets.
When would you NOT use chained else-if statements?
When there are multiple, mutually exclusive conditions
When only one condition can be true at a time
When you need to run the same block of code for all conditions
When you are checking ranges of numbers
Which of the following is a disadvantage of using too many chained else-if statements?
They can be hard to read and maintain.
They execute all the conditions.
They only work for numerical values.
They cannot be nested.
This is a catch-all for every other situation besides the one where the condition is true.
then
do
else
if
If you want to test more than one condition (chained condition), what do you use after if statement?
elif
else
ifif
else if
Data type that can only be true or false
int
string
boolean
float
Which character must be at the end of the line for if?
:
;
.
{
Which symbol means "not equal to"?
==
<=
>=
!=
What is the output?
250.0
200.0
300.0
350.0
What will display at the end of the program running?
You can ride the carousel!
Nothing will display
Sorry! Not tall enough!
There will be an error.
What is the output?
next
stop
next
stop
syntax error - program doesn't work
What is the output?
3
3
7
3
5
7
7
What is the output?
True
NIL
True
NIL
True
NIL
NIL
What is the output?
level 3
level 3
level 1
level 3
level 1
NIL
level 3
level 2
level 1
NIL
Given the nested if-else below, what will be the value x when the code is executed successfully.
0
4
2
3
Given the nested if-else structure below, what will be the value of x after code execution completes.
2
0
3
4
What is a conditional?
if clause
asks a yes or no question
decides whether to skip a section of code
code that might be skipped
