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.5 Getting User Input

45 Minutes

Lesson Overview

After an introduction to Marty using the Python library martypy, students will be asking users for input to create a chatbot interface for Marty and have control of movements. To do this, they will need to use variables to store the replies from users and use this input to alter how Marty moves.

Key vocabulary:
    Python, Chatbot, Variables, String, Number/Integer/Float, User Input,

Content Sections

  • Learning Objectives
  • Extensions & Challenges
    • Additional Reading
    • 3.5 Getting User Input

      45 Minutes

      Lesson Overview

      After an introduction to Marty using the Python library martypy, students will be asking users for input to create a chatbot interface for Marty and have control of movements. To do this, they will need to use variables to store the replies from users and use this input to alter how Marty moves.

      Key vocabulary:
        Python, Chatbot, Variables, String, Number/Integer/Float, User Input,
      • 3.1-3.4
      • Laptop or PC
      • Technologies/Literacy/Numeracy
        • Marty the Robot
        • Student workbooks (Lesson 1)
        • Devices with a Python editor and martypy installed

      Learning Objectives

      • Explore chatbots and describe different use cases
      • Describe what variables are and how they are used
      • Understand that values stored in a program may be of different types
      • Use sequence and variables to design and create a chatbot program in Python

      1. Discussion of what a chatbot is with students, exploring different chatbots available online

      a. What are some of the different use cases for chatbots?

      b. What features make a chatbot feel realistic when you’re chatting to it?

      c. What ethics would you have to consider when designing and creating a chatbot?

      2. Demonstrate example script for Marty chatbot to show students what they will be working on today

      3. Ask students what they think they will need to create this kind of program? What programming constructs and concepts? Students will need to gather user input and use variables to store and explore the input

      4. Discussion with students about variables

      a. Have they seen or used variables before? What is the definition of a variable?

      5. Showing students a basic example script (in PPT slides) ask them to highlight where they think the variables are

      6. Students begin to design and code their simple chatbot, asking the user questions and using Marty movements to compliment the chatbot responses

      7. Ask students what type of values/data they have been gathering from the user so far?

      a. Values/data that is made up of text are called strings

      b. Highlight that Python assumes each input from the user will be in string form so they will need to change it to be a number or integer in order to process a number (for example, if asking the user how many steps Marty should take)

      8. Challenge students to ask the user for values/data that they can change into integers and include that in their chatbot programs

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

      Extensions & Support

      • Ask other student groups to test out the chatbot and give feedback on how they could make it better or more realistic (Literacy/Technologies)
      • Explore the history of chatbots further by researching artificial intelligence and studies including The Turing Test and Chinese Room debating whether computers can think and create a short video/presentation/animation (Literacy/Technologies/Social Studies)
      • Create a poster with instructions and tips on creating a realistic chatbot (Arts/Literacy/Technologies)

      Additional Reading

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