Input and Output in Python
Learning Objectives:
● Students will understand the concept of input and output in Python.
● Students will be able to use the print() function to display messages.
● Students will be able to use the input() function to get user input.
● Introducing Variables.
● Students will be able to combine input and output to create interactive programs.
Materials:
● Whiteboard or projector
● Markers or pens
● Computers with Python installed (or access to a web-based Python environment)
● Handout with basic Python syntax (optional)
Lesson Outline:
Introduction (10 minutes):
● Start by discussing the concept of communication between humans and
computers.
○ How do humans communicate together?
○ How can humans talk to the computer?
● Introduce the terms input (data provided to the computer) and output (data
displayed by the computer).
● Briefly explain what programming languages are and how they are used to give
instructions to computers.
Activity 1: Hello World! (15 minutes):
1. Introduce the print() function in Python as a way to display messages on the
screen.
2. Demonstrate a simple program that uses print() to display "Hello, World!".
3. Guide students through writing their own "Hello, World!" program.
4. Encourage them to experiment with different messages using print().
Activity 2: Getting User Input (20 minutes):
1. Introduce the input() function as a way to get data from the user.
2. Demonstrate a program that uses input() to prompt the user for their name and
then prints a greeting message.
3. Explain how input() always returns a string, even for numbers.
4. Guide students through writing a program that asks for the user's age and then
prints it back.
5. Challenge students to write a program that asks for two numbers, adds them
together, and displays the result.
Wrap-up (5 minutes):
● Briefly review the key concepts of input and output in Python.
● Answer any remaining questions from students.
● Provide resources for further learning (e.g., online tutorials, practice problems).
Assessment:
● Observe students' participation during the activities.
● Review their completed code from the activities.
● Ask students to explain their code and how it uses input and output.
Differentiation:
● For advanced students, provide challenges that involve more complex input and
output manipulations, like formatting user input or type conversions.
● For struggling students, offer additional support and break down the activities into
smaller steps.
Extension Activities:
● Introduce variables to store user input and perform calculations.
● Write programs that read data from files or write data to files.