80-Minute Session Plan: Variables and Basic Input/Output
Programming Language: Python Pair-Programming Topic: A basic personalized greeting program
Learning Outcomes
By the end of this session, students will be able to:
- Define what a variable is in the context of programming and explain its purpose.
- Identify common data types (integer, float, string, boolean) and provide examples.
- Declare variables and assign values to them using Python syntax.
- Use the
print() function to display information to the console. - Use the
input() function to receive text input from a user. - Collaborate with a partner to write a simple Python program that uses variables and basic I/O.
Pre-Work (Optional Review)
- Review a short video introduction to what programming is and its role in daily life (e.g., a 5-minute clip on Khan Academy or Codecademy).
- Read a brief overview of how computers store different kinds of information.
Session Opening (7 minutes)
- Activity: "Think-Pair-Share" (3 minutes): Pose the question: "How do computers remember things? If you type your name into a website, how does the computer hold onto it?" Students think individually, then discuss with a neighbor.
- Share-Out: (2 minutes) Invite a few pairs to share their ideas. Guide the discussion towards the idea of storing information temporarily.
- Agenda & Relevance: (2 minutes) Briefly outline today's session: we'll learn about variables (how computers 'remember'), and how to talk to our programs (input/output). Explain that these are the building blocks for all programs.
Core Segments (45 minutes)
- Introduction to Variables (15 minutes):
* Concept Explanation: What is a variable? (A named storage location for data). Analogy: a labeled box holding a value. Why do we use them? (To store data that can change, reuse values, make code readable). * Live Coding & Discussion: Demonstrate variable declaration and assignment in Python (name = "Alice", age = 25, pi = 3.14). Discuss basic data types: int, float, str, bool. Ask students to predict the output of simple assignments and reassignments. * Group Activity: Quick discussion: "What kind of data type would you use for a student's GPA? A student's ID number?"
- Basic Output (`print()`) (15 minutes):
* Concept Explanation: How programs talk to us. The print() function. * Live Coding & Discussion: Demonstrate print("Hello world!"), print(name), print("My age is", age). Show f-strings for formatted output (print(f"Hello, {name}!")). Encourage students to try predicting output for various print statements combining strings and variables.
- Basic Input (`input()`) (15 minutes):
* Concept Explanation: How we talk to programs. The input() function. Emphasize that input() always returns a string, requiring type conversion if numbers are needed later. * Live Coding & Discussion: Demonstrate user_name = input("What is your name? "), then print(f"Nice to meet you, {user_name}!"). Show how to get numerical input and convert it: age_str = input("How old are you? "); age_int = int(age_str). Discuss potential errors if conversion fails.
Active-Learning Task: Pair-Programming (20 minutes)
- Instructions: Students work in pairs. One student drives (types), the other navigates (guides and reviews). Switch roles halfway through.
- Problem Statement: Write a Python program that asks the user for their name and their favorite color. The program should then print a personalized greeting that includes their name and favorite color, for example: "Hello [Name]! I see your favorite color is [Color]. That's a great choice!"
- Facilitation: Circulate, answer questions, prompt students to explain their code to each other.
Low-Stakes Assessment: Exit Quiz (8 minutes)
- Instructions: Individual, short, paper-based or online quiz.
- Questions (Example):
1. What is the purpose of a variable in programming? 2. Which Python data type would be most appropriate for storing someone's email address? (a) int (b) float (c) str (d) bool 3. Write a single line of Python code that asks the user for their hometown and stores it in a variable called my_hometown.
Follow-Up Readings/Practice
- Textbook: Read Chapter 2 on Variables and Data Types.
- Online Tutorial: Complete the "Variables and I/O" module on a platform like Codecademy or W3Schools Python tutorial.
- Practice: Write a simple Python program that calculates the area of a rectangle, taking length and width as input from the user.