wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

U6/L4 HS Kira- Elif Statements

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.

Ty Redman is teaching his friends Sapil, Seth, and Hunter about programming. He says, "Alright y'all, imagine you're deciding what to eat for dinner. You check if you want pizza first, but if not, you check if you want burgers, and if that's not it, maybe tacos!" Which statement best describes what an elif does in this scenario?

a)

A conditional that checks a single condition once

b)

A conditional statement that allows multiple conditions to be checked in sequence

c)

A loop that repeats code until a condition is false

d)

A function that returns a Boolean value only

2.

Ty Redman and his buddy are coding up a storm in Python, and they hit a snag when they see the elif keyword. Ty’s like, “Wait, what does elif actually stand for?” Can you help them out?

a)

else if

b)

else for

c)

end if

d)

each if

3.

Yo, it's Ty Redman here! Imagine Jackson, Layla, and Micah are battling for the last cookie, and they're using a chain of if, elif, and else statements to decide who snags it. Which code block actually gets to run?

a)

All blocks whose conditions are true

b)

Only the last block in the chain

c)

Only the first block whose condition is true

d)

None of the blocks if any condition is true

4.

Yo, imagine Paula and Jackson are coding up a storm in Python, just like Ty Redman would! They’ve got a bunch of different things to check in their program. When’s the right time to drop an elif in their conditional logic?

a)

When you have exactly two possible conditions to check

b)

When you have more than two possible conditions to check

c)

When you want the code to always run regardless of conditions

d)

When you need to stop a loop immediately

5.

Ty Redman and his buddy are working on a Python project! Ty asks: What’s a major difference between elif and else in Python?

a)

elif cannot have a condition, but else must

b)

elif must have a condition, while else does not

c)

Both elif and else must have conditions

d)

Neither elif nor else can appear after an if

6.

Alright, imagine Layla and Jordan are working on their smart robot, just like I would in my garage! Which statement best describes what conditional logic lets their robot do in real life?

a)

Make automatic decisions based on whether conditions are true or false

b)

Store multiple variables in a single data structure

c)

Repeat a block of code a fixed number of times

d)

Convert input data types without errors

7.

Ty Redman and his buddy are working on a coding project together, and Ty wants to keep things chill and organized instead of having a wild mess of separate if statements everywhere. Why does using the if/elif/else structure help Ty and his friend keep their code neat and easy to read?

a)

Separate if statements are always slower than loops

b)

Multiple separate if statements can be less efficient and harder to read

c)

Elif automatically saves variables across functions

d)

Else blocks can only be used once per program

8.

Ty Redman and his buddies are coding a game in Python. They set up an if/elif/else chain to figure out what happens next in their game. How does Python decide which block of code to run?

a)

From the last condition to the first, then loops back

b)

Randomly selects one condition to test

c)

From top to bottom, stopping at the first condition that is true

d)

Evaluates all conditions and runs every matching block

9.

Yo, imagine Layla and Micah are jamming on some code, stacking up those elif statements like pizza slices, but they totally forget to drop a final else at the end. What kind of trouble could that cause in their program?

a)

Infinite loops due to repeated checks

b)

Missing cases that are not covered by any condition

c)

Variables being deleted unexpectedly

d)

Syntax errors that stop the program from running

10.

Hey y'all, it's Ty Redman here! Imagine Carter, Layla, and Collier are out at the beach playing a game called “Grab Some Crabs.” If you were coding their game, what would be a fun and reasonable way to use an elif statement?

a)

To define a function to sort the crabs by size

b)

To handle a specific case such as the crab being medium, small, or large

c)

To import graphics libraries for crab sprites

d)

To save the game state to a file

11.

Alright y'all, imagine Hunter, Carter, and Kenzie are teaming up to code, just like Ty Redman would rally the crew! What's a solid organizational tip that can help them lay out multiple conditions efficiently and keep their code looking clean?

a)

Place the most likely or specific conditions in a logical order

b)

Always put else before elif

c)

Write all conditions on a single line separated by commas

d)

Avoid using comparison operators in conditions

12.

Alright y'all, imagine Ty Redman and his buddies are working on some code. If none of their if or elif conditions hit true, which block is gonna run (assuming it's there)?

a)

try block

b)

finally block

c)

else block

d)

except block

13.

Alright y’all, Ty Redman here! Layla, Paula, and Carter are gearing up for a picnic and gotta figure out what to wear based on the temperature. So, let’s say temperature = 72. Which pair of conditions would you use to print “It’s hot.” for temps 85 or above, “It’s warm.” for 65–84, and “It’s cold.” for anything else?

a)

if temperature > 72: elif temperature == 72:

b)

if temperature >= 85: elif temperature >= 65:

c)

if temperature >= 65: elif temperature >= 85:

d)

if temperature > 84 and temperature < 65: elif temperature <= 84:

14.

Ty Redman and his friends are coding a game in Python. They're trying to figure out the best way to check what happens when a player makes a move. Why would Ty choose to use an elif chain instead of just writing a bunch of separate if statements?

a)

It guarantees faster input from the keyboard.

b)

It ensures only the first true condition runs, preventing multiple branches from executing.

c)

It automatically sorts the outcomes alphabetically.

d)

It removes the need to test any conditions at all.

15.

Skill/Concept: Yo, imagine Ty Redman and his friends are chilling at the lunch counter, and they gotta pick their meal by punching in a number: 1 = Pizza, 2 = Salad, 3 = Sandwich. Which code setup would let them use elif so their choices are smooth and nobody gets mixed up?

a)

Three separate if statements, each printing the chosen meal.

b)

One if for choice 1, one else for all other choices, and another if after it for choice 3.

c)

An if for choice 1, elif for choice 2, elif for choice 3, and else for invalid input.

d)

Only an else statement that prints the meal name based on the number.

16.

Ty Redman style: Picture this—Paula and Jordan are cooking up a wild multi-branch program, and Ty Redman strolls in and says, "Hey, let's swap all those elif statements for else blocks!" Next thing you know, their code is serving up totally wrong results. What’s the most likely reason for this coding catastrophe?

a)

Else blocks stop evaluating conditions, so different valid cases collapse into the same default path.

b)

Else runs faster than elif, causing timing bugs.

c)

Elif only works with numbers, while else works with strings.

d)

Python does not allow more than one elif in a program.