Skip to content
PlayOwl

Coding worksheet · Computers & Digital Literacy

Trace the conditions: which branch runs? · Grade 7

Read 6 short Python programs about if, elif and else with and/or conditions and work out by hand what each one prints or the final value of a variable. Builds careful code tracing.

  • Grade 7 · ages 12 to 13
  • Easy
  • 35 to 45 minutes
  • 1 page
  • Free
Paper

The answer key is a separate page for grown-ups. Sign in to download it.

Make another one like this

Directions: Trace each program line by line without a computer. Keep a note of every variable as it changes, then write exactly what the program prints or the final value.

  • 1 What is printed?
  • 1 mark = 58
  • 2 if mark >= 90:
  • 3 print("gold")
  • 4 elif mark >= 70:
  • 5 print("silver")
  • 6 elif mark >= 50:
  • 7 print("bronze")
  • 8 else:
  • 9 print("keep practicing")
  • 2 What is printed?
  • 1 nums = [8, 16, 19, 3, 12, 17]
  • 2 total = 0
  • 3 for n in nums:
  • 4 if n > 8:
  • 5 total += n
  • 6 print(total)
  • 3 What is printed?
  • 1 def bigger(a, b):
  • 2 if a > b:
  • 3 return a
  • 4 return b
  • 5 print(bigger(3, 14) * 3)
  • 4 What is printed?
  • 1 age = 7
  • 2 height = 126
  • 3 if age >= 8 or height >= 134:
  • 4 print("ride")
  • 6 print("wait")
  • 5 What is printed?
  • 1 total = 0
  • 2 for i in range(1, 6):
  • 3 if i % 2 == 0:
  • 4 total += i
  • 5 print(total)
  • 6 What is big at the end?
  • 1 a = 15
  • 2 b = 16
  • 3 if a > b:
  • 4 big = a
  • 6 big = b

What your child practices

Your child builds careful code tracing. The skill is “Conditions”: use if/else to respond to situations.

Grades and ages
Grade 7, ages 12 to 13
Time
About 35 to 45 minutes
Subject
Computers & Digital Literacy
Level
Easy for Grade 7
Answer key
Yes, for grown-ups who sign in
Printing
1 page, US Letter or A4, low-ink option
Updated

How to use it

Work through the first program together, one line or arrow at a time. Then let your child work through the rest, showing their thinking on the page. It is one of the easier sheets for Grade 7, good as a warm-up or a first look at the skill.

An answer key comes with it as a separate page that grown-ups download after signing in.

Tip for grown-ups: Have your child write each variable's value beside its line as they trace.

Done on paper? A grown-up can record it on the child's page in PlayOwl; downloading alone doesn't count as finished.

Printable generator

Make your own printables

Make brand-new sheets like this one, with answer keys, using the printable generator that comes with a PlayOwl plan. This sheet stays free.