Description
Intro to Python: Text-Based Coding (Grades 5–8)
Lesson 5 – Loops & Import Libraries
In this 3–7 day lesson, students build on their foundational Python skills by learning how to repeat actions, control program flow, and add randomness using for loops, while loops, and imported libraries. After exploring loops in isolation, students apply their knowledge by creating interactive programs- culminating in a loop-based guessing game and a Rock, Paper, Scissors–style game.
This lesson is designed for upper elementary and middle school students and is perfect for coding beginners who are ready to move beyond basic conditionals and into more dynamic, game-like programs.
*More to Come:
This lesson fits within a larger Intro to Python: Text-Based Coding unit that is being developed into a lessons 1–5 bundle!
What’s Included:
- Comprehensive 30 page Google Slides presentation with step-by-step instruction, visuals, and real Python code examples
- Google Doc planning worksheets to help students organize logic and program flow
- Guided coding challenges using an online Python console (no downloads or installs required)
- Real-world coding examples that show how loops function in authentic programs
- Program evaluation rubric for easy and consistent assessment
Students Will Learn To:
- Understand and apply for loops and while loops
- Prevent and fix infinite loops
- Use input() to create interactive programs
- Import and use Python libraries (including random)
- Build logic using nested if / elif / else statements
- Create looping games that track score and allow users to exit properly
Project-Based Coding Applications:
Students don’t just read code- they write it. In this lesson, students will:
- Create a repeating guessing game that runs until the correct answer is entered
- Design and code a Rock, Paper, Scissors–style game using loops, variables, and imported libraries
- Practice debugging, formatting, and improving program readability
The lesson emphasizes logical thinking, persistence, and problem-solving, while keeping students engaged through interactive game design.
ISTE Standards:
This lesson supports the ISTE Standards for Students by engaging learners as Empowered Learners (1.1) and Computational Thinkers (1.5) while encouraging problem-solving, creativity, and perseverance through the Innovative Designer (1.4) standard. Students apply algorithmic thinking and logical reasoning as they design, test, and refine looping Python programs.
Classroom-Friendly & Flexible:
- Works on any device with a browser
- No software installation required (Trinket)
- Can be taught as a standalone lesson or as Lesson 5 in a larger Python unit
- Easily adaptable for grades 5–8 based on pacing and depth
This resource is ideal for Computer Science classes, STEM labs, enrichment, or technology electives.
If you find any errors or have questions, please use the Questions & Answers tab- I’m always happy to help.
Please consider following my store and leaving a review. Your feedback helps other teachers and earns you TPT credits toward future purchases.
Looking for the full unit?
This lesson is part of my Intro to Python: Text-Based Coding sequence and is included in a discounted bundle covering lessons 1–5.
From one teacher to another- THANK YOU for your support!
Intro to PYTHON Coding: Loops & Import (Lesson 5, Grades 5–8)
Highlights
Save even more with bundles
Description
Intro to Python: Text-Based Coding (Grades 5–8)
Lesson 5 – Loops & Import Libraries
In this 3–7 day lesson, students build on their foundational Python skills by learning how to repeat actions, control program flow, and add randomness using for loops, while loops, and imported libraries. After exploring loops in isolation, students apply their knowledge by creating interactive programs- culminating in a loop-based guessing game and a Rock, Paper, Scissors–style game.
This lesson is designed for upper elementary and middle school students and is perfect for coding beginners who are ready to move beyond basic conditionals and into more dynamic, game-like programs.
*More to Come:
This lesson fits within a larger Intro to Python: Text-Based Coding unit that is being developed into a lessons 1–5 bundle!
What’s Included:
- Comprehensive 30 page Google Slides presentation with step-by-step instruction, visuals, and real Python code examples
- Google Doc planning worksheets to help students organize logic and program flow
- Guided coding challenges using an online Python console (no downloads or installs required)
- Real-world coding examples that show how loops function in authentic programs
- Program evaluation rubric for easy and consistent assessment
Students Will Learn To:
- Understand and apply for loops and while loops
- Prevent and fix infinite loops
- Use input() to create interactive programs
- Import and use Python libraries (including random)
- Build logic using nested if / elif / else statements
- Create looping games that track score and allow users to exit properly
Project-Based Coding Applications:
Students don’t just read code- they write it. In this lesson, students will:
- Create a repeating guessing game that runs until the correct answer is entered
- Design and code a Rock, Paper, Scissors–style game using loops, variables, and imported libraries
- Practice debugging, formatting, and improving program readability
The lesson emphasizes logical thinking, persistence, and problem-solving, while keeping students engaged through interactive game design.
ISTE Standards:
This lesson supports the ISTE Standards for Students by engaging learners as Empowered Learners (1.1) and Computational Thinkers (1.5) while encouraging problem-solving, creativity, and perseverance through the Innovative Designer (1.4) standard. Students apply algorithmic thinking and logical reasoning as they design, test, and refine looping Python programs.
Classroom-Friendly & Flexible:
- Works on any device with a browser
- No software installation required (Trinket)
- Can be taught as a standalone lesson or as Lesson 5 in a larger Python unit
- Easily adaptable for grades 5–8 based on pacing and depth
This resource is ideal for Computer Science classes, STEM labs, enrichment, or technology electives.
If you find any errors or have questions, please use the Questions & Answers tab- I’m always happy to help.
Please consider following my store and leaving a review. Your feedback helps other teachers and earns you TPT credits toward future purchases.
Looking for the full unit?
This lesson is part of my Intro to Python: Text-Based Coding sequence and is included in a discounted bundle covering lessons 1–5.
From one teacher to another- THANK YOU for your support!





