Technology and Computer Science Computer Science

Conditionals: Tracing If, Else If and Else

Students read an original passage on conditionals and comparison operators, then answer 11 questions (two multiple choice) that ask them to trace if, elif and else code by hand, spot an ordering bug and write a short decision chain of their own.

Grades 7-1045 minutesSP-CS-022

THE GOAL

What students will learn

Students explain how a program uses conditions to make decisions, read comparison operators, and trace if, elif (else if) and else chains by hand to predict exactly which branch runs.

BEFORE THE BELL

Get ready

Copy the reading and worksheet (pages 3-5) for each student. Write the warm-up question on the board before class.

KEEP THE PLAN CLOSE

Your teacher guide

Teacher directions only. Student worksheets and the answer key are in the complete PDF.

CONDITIONALS: TRACING IF, ELSE IF AND ELSE
Grades 7-10 | 45 minutes | SP-CS-022

THE GOAL
Students explain how a program uses conditions to make decisions, read comparison operators, and trace if, elif (else if) and else chains by hand to predict exactly which branch runs.

BEFORE THE BELL
Copy the reading and worksheet (pages 3-5) for each student. Write the warm-up question on the board before class.
- Student reading (page 3)
- Worksheet (pages 4-5)
- Pencils
- Scrap paper for tracing

STEP BY STEP
1. (5 min) Warm-up: Post this question: "You check the weather before school. Write the rule you use to decide what to wear, starting with the word IF." Students write one or two rules. Call on two volunteers to read theirs aloud.
2. (12 min) Read: Hand out the reading. Students read silently and circle every comparison operator they see (such as >, >= and ==). Offer to read the first paragraph aloud for anyone who wants it.
3. (18 min) Worksheet: Students complete questions 1-11. For tracing questions, tell them to check each condition from the top, write True or False next to it, and stop at the first True.
4. (5 min) Partner check: Partners compare answers to the tracing questions (4-10). If they disagree, they trace the code together one line at a time, writing True or False beside each condition.
5. (5 min) Exit ticket: Students answer the exit ticket at the bottom of the worksheet. Collect everything in one stack.

NOTES FOR YOU
- You do not need to know how to code. The answer key gives every output, and the method (check each condition top to bottom, stop at the first True) is all students need.
- The most common mistake: thinking more than one branch of an if/elif/else chain can run. Only the first True branch runs; everything below it is skipped.
- Watch for students who say 90 > 90 is True. It is False; 90 >= 90 is True. Question 5 and the exit ticket test this on purpose.

EXIT TICKET (read aloud or post)
In the weather code from question 4, what prints when temp = 70? Explain in one sentence.

EARLY FINISHERS
Early finishers write an if/elif/else chain for a movie theater that prints "Child" for ages under 13, "Teen" for 13 to 17 and "Adult" for 18 and up, then trace it for ages 12, 13 and 18.

PAGES TO COPY: only pages marked STUDENT PAGE in the complete PDF. Answers are on the last teacher page.

READY WHEN YOU ARE

Take the plan with you.

Teacher copy — includes the answer key.

The complete PDF includes welcome pages, substitute directions, student worksheets, and answers. Give students only the worksheet pages. Check the page labels before you print or share.

Download complete teacher PDF

Opens the PDF in a new tab. Use its print controls to select the student pages you need.

Download teacher phone guide

A readable guide that opens offline in your browser. Student worksheets and answers are not included.

Free lesson · SP-CS-002Guide ↓PDF ↓

QUICK ANSWERS

In short:

This free 45-minute Computer Science sub plan for grades 7-10 teaches conditionals: if, elif (else if) and else, plus comparison operators such as == and >=. Students read a short passage and trace Python-style decision code by hand on 11 questions, with no computers needed. Answer key included.

Frequently asked questions

What is the difference between if, elif and else in Python?

if checks the first condition. elif (short for else if) checks another condition only when every condition above it was False. else runs when none of the conditions were True. In one chain, only one branch runs.

Why does the order of elif statements matter?

The computer stops at the first True condition. If a broad check such as score >= 70 comes before a stricter one such as score >= 90, the stricter branch never runs. Put the strictest condition first.

Can a substitute teach this coding lesson without knowing how to program?

Yes. It is paper-only, students trace code by hand, and the answer key gives the exact output and the True/False reasoning for every tracing question.

What grade level is Conditionals: Tracing If, Else If and Else for?

It is written for grades 7-10 in Technology and Computer Science (Computer Science).

How long does Conditionals: Tracing If, Else If and Else take?

Plan on about 45 minutes. The teacher guide breaks the period into timed steps a substitute can follow.

What does the substitute need to prepare?

Copy the reading and worksheet (pages 3-5) for each student. Write the warm-up question on the board before class.

Does this lesson need technology?

None. Paper and pencil only. Students trace code by hand; no computers needed.

Is there an answer key?

Yes. The free complete PDF (6 pages) includes substitute directions, the student pages, and a teacher answer key on pages marked TEACHER PAGE.