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.6 IF statements

45 Minutes

Lesson Overview

Students have started to create their chatbots using variables and understand the difference between strings and integers. In this lesson, we will introduce if statements to students to incorporate into the chatbots so that they can begin to make decisions their programs based on the user input to create a more responsive chatbot for Marty.

Key vocabulary:
    Decision Making, Chatbot, Variables, If Statements, Control, User Input,

Content Sections

  • Learning Objectives
  • Extensions & Challenges
  • Additional Reading
  • 3.6 IF statements

    45 Minutes

    Lesson Overview

    Students have started to create their chatbots using variables and understand the difference between strings and integers. In this lesson, we will introduce if statements to students to incorporate into the chatbots so that they can begin to make decisions their programs based on the user input to create a more responsive chatbot for Marty.

    Key vocabulary:
      Decision Making, Chatbot, Variables, If Statements, Control, User Input,
    • 3.1-3.5
    • Laptop or PC
    • Technologies/Literacy
      • Marty the Robot
      • Student workbooks (Lesson 2)
      • Devices with a Python editor and martypy installed

    Learning Objectives

    • Describe when you might use an if statement
    • Use sequence, variables and if statements to extend the chatbot to make decisions based on the user input
    • Explore different approaches to responding to user input through text and Marty movements

    1. Recap on what the students did in the last lesson

    a. What did they like about the chatbots? What did they want to try and improve about their chatbots?

    b. What programming constructs and concepts were used?

    2. Discuss with students in more detail what might make the chatbots better, for example, being able to respond to different keywords that the user has entered

    3. Demonstrate example script to show students what they will be working on in the lesson

    4. Explain that they will need to use if statements to check what the user has entered

    a. What are if statements? Have the students used them before? What for?

    b. Discuss examples of if statements in real life with students using examples from the workbook

    5. Students continue work on their chatbots, incorporating if statements and regularly testing with other groups

    6. Students should complete the end of lesson reflection section of their workbooks

    Extensions & Support

    • Ask students to list ways to make their chatbots feel more realistic (Technologies/Literacy)
    • Can students think of a way to accept different synonyms for walk so that their chatbot can respond to a variety of words? They might want to think about lists in Python (Technologies/Literacy)

    Additional Reading

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