Lenny.com
Explore
Create
ActivitiesNewMathEnglish Language ArtsScience & EngineeringSocial StudiesGlobal LanguagesHealth & Physical EducationSpecial EducationCounseling & Life SkillsArts & CreativityESL
Lenny.com
Lenny.com
Explore
Create
ActivitiesNewMathEnglish Language ArtsScience & EngineeringSocial StudiesGlobal LanguagesHealth & Physical EducationSpecial EducationCounseling & Life SkillsArts & CreativityESL
Lenny.com
Lenny.com

Solutions

Lenny for EducatorsLenny for SchoolsLenny for Districts

Product

ExploreSign inCreateSupportAbout

Resources

Getting startedMTSS Acceleration Program

Newsletters

School Funding Newsletter

© 2026 Lenny Learning Inc.

TermsPrivacyAccessibility
LinkedInInstagramX
Lenny
Science & EngineeringLife ScienceLiving ThingsAnimalsPlantsBody SystemsTraitsAdaptationsCellsEcosystemsHeredityGenes to TraitsCell DivisionPhysicsComparing MaterialsShapes and PropertiesMagnetsMagnetismLightSoundLight and SoundMatterStates of MatterChanges of StateMixturesPhysical and Chemical ChangeHeating and CoolingHeat and Thermal EnergyEnergyForce and MotionElectrical CircuitsAtoms and MoleculesPeriodic TableMotion in One DimensionMotion in Two DimensionsScalars and VectorsForces and Laws of MotionCircular Motion and GravityMomentum and ImpulseWork, Energy, and PowerWavesElectromagnetic WavesGeometric OpticsElectricity and MagnetismSimple Harmonic MotionThermodynamicsNuclear PhysicsEarth Science & AstronomyWeatherWater CycleRocks and MineralsFossilsEarth's FeaturesEarth's ResourcesEarth's StructureWeather and ClimateEarth EventsFossils and Geologic TimePlate TectonicsHuman ImpactsAstronomyChemistryUnits and MeasurementAtomic StructurePeriodic TrendsChemical BondingNomenclatureMolecular StructureIntermolecular ForcesThe MoleStoichiometryProperties of GasesSolutionsChemical ReactionsBalancing EquationsEnergy ChangesRates of ReactionsEquilibriumAcids and BasesQuantum ModelBiologyClassificationCell StructureThe Chemistry of LifeBiomoleculesCellular TransportCell EnergyCell Growth and DivisionDNAProtein SynthesisMeiosis and Sexual ReproductionPatterns of InheritanceMulticellular OrganismsEvolutionEcologyBiodiversityComputer ScienceAlgorithms and Computational ThinkingProgramming LanguagesComputing SystemsNetworks and InternetData AnalysisCybersecurityAI and Machine LearningSoftware Design and DevelopmentBlockchainEngineering & AIDesigning ExperimentsEngineering PracticesDesign ThinkingEngineering Design ProcessMechanical EngineeringElectrical EngineeringMaterials and StructuresCAD and 3D DesignRoboticsArtificial Intelligence BasicsVibe CodingMachine LearningAI Ethics and SocietySystems ThinkingEntrepreneurship & InnovationEntrepreneurial MindsetBusiness Idea DevelopmentBusiness Plan BasicsMarketing & Customer DiscoveryFinancial Management for Startups

Repetition and Logic

A multi-day Python computing sequence preparing students to upgrade Rock-Paper-Scissors into a five-round match using loops and variable counters.

BFBrandi Flanigan
Understanding Loops

Explores the mechanics of Python for loops, iterating through lists, and using range() with step-by-step trace diagrams and Colab practice.

Counters and Scorekeeping

Focuses on updating integer variables in Python, comparing score = score + 1 to the += 1 shortcut, and maintaining multi-round game counters inside a loop.

Repetition and Logic

A multi-day Python computing sequence preparing students to upgrade Rock-Paper-Scissors into a five-round match using loops and variable counters.

BFBrandi Flanigan

Terminal Output:

1 2 3 4 5

Watch the Score Accumulate:

Before Loop: score = 0

Round 1 (i = 0): score = 1

Round 2 (i = 1): score = 2

Rounds 3-5: score grows to 5

Crucial Pattern: We start the score at 0 before the loop begins so it can keep counting up!

🔁 Every time the indented code runs, score += 1 adds 1 to the existing total.


Code Along

Try It in Google Colab

Slide 6 / 14

1

Open Your Colab Notebook

Create a new code cell for Wednesday's practice.

2

Type and Run the Code

Watch the numbers count up from 1 to 5.

★

Experiment:

Change range(5) to range(10). What is the final number printed?

counting_loop.py Colab

score = 0

for i in range(5):
    score += 1
    print("Current score:", score)

💡 Each pass through the loop, the variable preserves its value from the previous pass! Shift + Enter to run


Indentation Matters

Where Does print() Belong?

Slide 7 / 14

Print Inside (Indented)

score = 0
for i in range(3):
    score += 1
    print(score)

Prints every single round: 1, 2, 3 (Running update)

Print Outside (Unindented)

score = 0
for i in range(3):
    score += 1

print(score)

Prints only ONCE at the end: 3 (Final score)

🏆 For our game, we'll want to print round scores inside and the final champion outside!


Two Players

Tracking Two Competitors

Slide 8 / 14

Two Separate Counters

# Set both scores to 0 before match
player_score = 0
computer_score = 0

for i in range(5):
    # Play round and give point...

Why Two Separate Variables?

In Rock, Paper, Scissors, both players start at zero. A win awards a point to only one player.

If player wins: player_score += 1

If computer wins: computer_score += 1

What if it's a tie round? Neither counter changes!

🎮 Two independent variables allow Python to track head-to-head competition!


Decisions & Points

Awarding Points with Conditionals

Slide 9 / 14

Conditional Score Update

winner = input("Who won? ")

if winner == "player":
    player_score += 1
elif winner == "computer":
    computer_score += 1
else:
    print("Tie round!")

Connecting to Conditionals

You already know how to check who won a round using if and elif.

Now, instead of just printing "You win!", we also award a point to the winner's counter.

⚡ This is the exact piece of code that will plug inside your RPS loop on Thursday!

🎯 When a round finishes, Python evaluates the outcome and increments the proper score.


Code Along

Code Along: Mock Match in Colab

Slide 10 / 14

mock_match.py Google Colab

player_score = 0
computer_score = 0

for i in range(3):
    winner = input("Winner (p/c)? ")
    if winner == "p":
        player_score += 1
    else:
        computer_score += 1

print("Final:", player_score, "to", computer_score)

Type and Run in Colab:

Colab will ask you 3 times who won. Type p or c each round.

Notice how the program remembers all 3 rounds and outputs the correct final score at the end!

🔍 Notice the last line is unindented — it runs only after all 3 rounds are finished!

⚡ You just built the core score-tracking engine for a multi-round game!


Declaring a Champion

After the Loop: Who Won the Match?

Slide 11 / 14

Final Win Condition (Outside Loop)

# After all 5 rounds finish:
if player_score > computer_score:
    print("🏆 You won the match!")
elif computer_score > player_score:
    print("🤖 Computer won the match!")
else:
    print("🤝 The match was a tie!")

Comparing the Final Totals

Because this code is NOT indented under the loop, Python waits until all 5 rounds have completed before running it.

It simply compares the two totals with > and crowns the overall champion!

🎉 This completes the full flow of our 5-round match architecture!

💡 Notice: The score logic is completely separate from the round gameplay itself.


Bug Hunt

Debugging Challenge: The Reset Trap

Slide 12 / 14

Spot the Devastating Bug

for i in range(5):
    score = 0
    score += 1
    print(score)

Trace & Predict

• What will this code print during each of the 5 repetitions?

• Why does score never reach 5?

• How do you fix it with one simple change?

⚠️ This is the #1 mistake students make with score counters in loops!

🔎 Discuss with your elbow partner — trace the value of score on pass 1, 2, and 3! No spoilers!


Practice Time

Colab Guided Practice (10 Mins)

Slide 13 / 14

1

Simple Counter

Create a variable points = 0. Add 1 three times using += 1 and print the result.

2

5-Round Accumulator

Put points += 1 inside a 5-round loop. Print only the final score outside the loop.

3

Scorekeeper with Input

Ask the user who won 3 rounds. Award a point to player_score or computer_score.

4

Champion Announcer

Add an if / elif / else block after the loop to announce who won the match!

🚀 Complete on your practice sheet or in Colab! Ask questions if your counter isn't saving!


Check Out

Exit Ticket & Thursday Payoff

Slide 14 / 14

1

What is the difference between score = score + 1 and score += 1?

2

Why must score = 0 be placed outside and before the loop?

3

Where does the code that declares the overall match champion belong: inside the loop or outside the loop? Why?

Tomorrow is the Block Day! You now have every single building block needed to turn your 1-round Rock, Paper, Scissors program into an epic 5-round tournament game!

✏️ Submit your responses on your exit slip before heading out! See you tomorrow!

4

Bug Hunt: The "Reset Trap"

for round in range(5):
    score = 0
    score += 1
    print(score)

A. What will this print on the 5 output lines?

B. Why does score never reach 5? What happens every pass?

C. How do you fix this bug? (Write the 1-line rule):

5

Thursday Scaffold: The 5-Round Match Blueprint

Fill in the blanks below to complete the full scorekeeping logic you will plug into Rock, Paper, Scissors tomorrow:

# Step 1: Initialize counters BEFORE the loop starts
player_score = ___
computer_score = ___

# Step 2: Loop exactly 5 rounds
for i in range(___):
    print("Starting Round", i + 1)
    # Step 3: Inside loop - update counters based on round winner
    if winner == "player":
        player_score ______
    elif winner == "computer":
        computer_score ______

# Step 4: OUTSIDE loop - determine and announce the overall winner
if player_score > computer_score:
    print("You won the match!")
elif ________________________:
    print("The computer won the match!")
else:
    print("The match was a tie!")

✍️ Check for Understanding

1. If two players tie a round in Rock, Paper, Scissors, what should happen to the scores?

2. Can an overall 5-round match end in a tie if every round has a winner? Why or why not?

Computing Foundations • Repetition & Logic Sequence Page 2 of 2

You might also like

Invisible Matter Slides

Matter Detectives

A comprehensive 5-day 5E science sequence for 5th grade exploring the particle nature of matter, properties of substances, conservation of mass, and chemical reactions through hands-on investigations.

CC

Caitlin Corr Reilly

10
DNA Architecture Slides

DNA Architecture

A comprehensive Regents Life Science lesson on the molecular architecture of DNA, covering nucleotide anatomy, antiparallel sugar-phosphate backbones, and complementary base pairing.

JE

Jeffrey Elterman

3
DNA Anatomy Worksheet

DNA Anatomy Worksheet

A 2-page student practice worksheet aligned with NYS Regents Life Science featuring diagram labeling of nucleotides and double-helix backbones, Chargaff's rule calculations, and Regents exam analysis.

JE

Jeffrey Elterman

Kelp Web Slides

Kelp Forest Forensics

A comprehensive 3-day investigative life science sequence exploring trophic cascades, keystone species, and ecological balance in Pacific kelp forests. Students examine authentic ecological data to diagnose ecosystem collapse and design science-backed restoration policies.

SM

Samantha McBath

6
Scorekeeping Slides

Counters and Scorekeeping

Focuses on updating integer variables in Python, comparing score = score + 1 to the += 1 shortcut, and maintaining multi-round game counters inside a loop.

BF

Brandi Flanigan

2
DNA Architecture Lesson Plan

DNA Architecture Lesson Plan

A 2-page standards-aligned lesson plan for NYS Regents Life Science covering DNA molecular structure, nucleotide anatomy, antiparallel backbones, and base-pairing energetics.

JE

Jeffrey Elterman

Motion Unlocked Reading Packet

Curriculum Unlocked

A sequence of high-interest, accessible 9th-grade reading lessons designed for students reading at a 5th-grade level across science and world history.

SH

Sarah Hunter

9
Understanding Loops Slides

Understanding Loops

Explores the mechanics of Python for loops, iterating through lists, and using range() with step-by-step trace diagrams and Colab practice.

BF

Brandi Flanigan

1
DNA Architecture Slides

DNA Architecture Slides

Interactive visual presentation for NYS Regents Life Science detailing the molecular structure of DNA, including nucleotide anatomy, antiparallel sugar-phosphate backbones, and complementary base pairing.

JE

Jeffrey Elterman

Cell Detectives Slides

Cell Explorers

A foundational life science unit for self-contained learners exploring the microscopic world of cells, organelle jobs, and how specialized cells work in teams to build living things.

CF

Carissa Fenner

8
Rainforest Rescue Lesson Plan

Rainforest Rescue

A comprehensive 4th grade science lesson where students explore tropical rainforest ecosystems, analyze human impacts, and engineer their own conservation action plan to protect biodiversity and natural resources.

Lenny Avatar
Lenny
4
Scorekeeping Practice Worksheet

Scorekeeping Practice Worksheet

Student-facing 2-page print worksheet on Python counters and scorekeeping. Includes variable trace tables, the += operator, loop accumulation tracing, debugging the loop reset trap, and scaffolding the 5-round match architecture.

BF

Brandi Flanigan