Unit 2 Task 14: Coin race to ten

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Unit 2 Task 14 - Coin race to ten

← Unit 2 tasks · Solution


Simulate coin flips with:

coin = random.randint(0, 1)  # 0 = Tails, 1 = Heads

Repeat until either heads or tails has appeared 10 times.

For each flip, print Heads or Tails.

At the end:

Use import random, a while loop, and if / elif as needed.

Skills: two counters, compound while condition.