How to use the
Learning Portal

Learning Portal

Our hands-on, comprehensive lesson plans span a range of levels. Browse our free STEM and coding learning resources.

Marty Image

3.11 Guess the number

45 Minutes

Lesson Overview

Students have now been introduced to two different types of loops in Python. Across the next two lessons students will design and build a number guessing game with Marty. To do this, students will need to differentiate between the two types of loops that have been covered so far.

Key vocabulary:
    For Loop, While Loop, Number , Condition, Control, User Input,

Content Sections

  • Learning Objectives
  • Extensions & Challenges
  • Additional Reading
  • 3.11 Guess the number

    45 Minutes

    Lesson Overview

    Students have now been introduced to two different types of loops in Python. Across the next two lessons students will design and build a number guessing game with Marty. To do this, students will need to differentiate between the two types of loops that have been covered so far.

    Key vocabulary:
      For Loop, While Loop, Number , Condition, Control, User Input,
    • 3.1, 3.2, 3.5, 3.6, 3.9, 3.10
    • Laptop or PC
    • Technologies/Literacy/Numeracy
      • Marty the Robot
      • Student workbooks (Lesson 3)
      • Devices with a Python editor and martypy installed

    Learning Objectives

    • Describe examples of when a for loop is needed
    • Describe examples of when a while loop is needed
    • Design and build a program that uses both a for and while loop
    • Draw a flowchart for a program with nested loops

    1. Recap on what the students were working on last time and reflect on what they have learned about loops

    a. What did you create in the last lesson? What coding concepts did you need to use?

    b. How is a while loop different to the loop we used in Lesson 1 (3.9)?

    2. Comparison of a while loop compared to the loop we used in the first lesson (called a for loop) in terms of how to write one in Python and the flowcharts for each

    3. Given some example programs, students need to decide whether they would need to use a while or a for loop to solve the problem

    4. Demonstrate to students the project they are going to be working on (example script provided) where they will need to design and build a guess the number game and discuss what coding concepts they think they will need to use

    5. In small groups, students should design their program by drawing a flowchart before beginning to code with Marty and Python (note that students will continue this project in the next lesson so may not fully finish by the end of the lesson)

    Extensions & Support

    See Lesson 3.12 for extensions

    Additional Reading

    • Marty the Robot Educator Guide
    • Educator FAQ
    • Getting Started with Python
    • MartyPy Documentation