0% found this document useful (0 votes)
23 views11 pages

5-Lesson Plan Introduction Python

This lesson plan introduces 8th-grade students to textual programming using Python, focusing on variables and their functions. Students will learn to create and manipulate variables, understand the assignment operator, and utilize functions like input(), eval(), and print(). The lesson includes assessments and homework assignments to reinforce the concepts taught.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views11 pages

5-Lesson Plan Introduction Python

This lesson plan introduces 8th-grade students to textual programming using Python, focusing on variables and their functions. Students will learn to create and manipulate variables, understand the assignment operator, and utilize functions like input(), eval(), and print(). The lesson includes assessments and homework assignments to reinforce the concepts taught.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Lesson Plan: Introduction to

Textual Programming
• Subject: Computer Science
• Topic: Introduction to Textual Programming
• Subtopic: Python and Variables
• Class: 8th
• Duration: 40 minutes
• Teacher: Muhammad Sikandar Dar
Student Learning Outcomes
By the end of this lesson, students will be able to:
• Identify key reasons why Python is a popular and useful programming
language.
• Define what a variable is and explain its purpose in a program.
• Create and assign a value to a variable using the assignment operator
(=).
• Utilize the input(), eval(), and print() functions to create an
interactive program.
• Trace the execution of code that updates variable values and predict
the final output.
• Differentiate between the roles of the assignment operator (=) and
mathematical equality.
Slide 2: Why Python?
• Popular & Powerful: A leading language for modern tech
(AI, data science, web development).
• Simple & Readable: Code is often shorter and easier to
read than other languages.
• Free & Cross-Platform: Runs on Windows, Mac, Linux,
and is free to use.
• Real-World Use: Used by YouTube, in traffic systems, e-
commerce, and scientific research.
Slide 3: What is a Variable?
• Definition: A named container that stores data in the
computer's memory.
• Analogy: A labeled box. The label is the variable name
(temp), and the contents are the value (38).
• Purpose: To hold data that can be used and changed
throughout a program.
Slide 4: Creating Variables:
Assignment
• The equals sign = is the assignment operator.
• It assigns the value on the right to the variable name on
the left.
• Example:
• x = 3 (Read as: "Assign the value 3 to the variable x")
• name = "Ali" (Assign the text "Ali" to the variable name)
• You can create a variable by simply assigning a value to a
name.
Slide 5: Using Variables: The Temperature Converter

• input() function: Pauses the program and gets text from the user.
• eval() function: Evaluates the input text as a Python number (e.g.,
converts "38" to 38).
• print() function: Displays output on the screen.
• Program Logic:
• temp = 0 (Create variable temp with initial value 0)
• temp = eval(input('Enter temperature: ')) (Get user input,
convert to number, store in temp)
• print(...) (Calculate Fahrenheit and print the result)
Slide 6: Updating Variable
Values
• A variable's value can be changed as many times as
needed.
• The new value overwrites the old one.
• Example from Program #2:
• z = x + y (z becomes 7)
• z = z + 1 (The new value of z is its old value (7) + 1. So z
becomes 8).
• Key Concept: The right side of the = is calculated first,
then the result is assigned to the left side.
Recapitulation
Let's quickly revise the key concepts:
• What is a variable? A named container that stores data in memory.
• What symbol is used to assign a value to a variable? The equals
sign =.
• What is the purpose of the eval() function
in eval(input(...))? To convert the user's text input into a number
that Python can calculate with.
• In the code z = z + 1, what happens? The program calculates the
value of z + 1 first, then takes that result and stores it back into the
variable z, overwriting its previous value.
• What is the output of print('Value of x: ', x)? It will print the
text "Value of x: " followed by the current value stored in the variable x.
Assessment (True/False)
Instructions: Read each statement carefully. Write 'T' for True and 'F' for
False.
• Python code is generally longer and more complex than code in other languages
like Java.
• A variable's value cannot be changed once it is first assigned.
• The input() function is used to display output on the screen.
• In the statement x = y, the value of y is copied and assigned to x.
• The eval() function is used to convert a number into text.
• The print() function can display both text and the value of variables.
• The statement z = z + 1 is an invalid statement in Python.
• Python is a free programming language that can run on different operating
systems.
Answer Key:
• F (Python code is known for being shorter and more readable)
• F (A variable's value can be updated many times)
• F (input() gets user input; print() displays output)
• T
• F (eval() converts text into a number)
• T
• F (It is a common and valid way to update a variable's value)
• T
Homework
Task: Write two simple Python programs to practice using variables.
• Program 1: The Rectangle Calculator
Write a program that calculates the area and perimeter of a rectangle.
• Create two variables: length and width.
• Use input() and eval() to get values for these variables from the user.
• Calculate the area (area = length * width).
• Calculate the perimeter (perimeter = 2 * (length + width)).
• Use print() to display the results clearly. (e.g., "The area is: 20")
• Program 2: Variable Switcher
Write a program that switches the values stored in two variables.
• Initialize two variables: a = 10 and b = 20.
• Print their values. (Output: a is 10, b is 20)
• Write code to swap the values. (Hint: You will need a third, temporary variable).
• Example: temp = a, then a = b, then b = temp.
• Print the values again to show they have switched. (Output: a is 20, b is 10)

You might also like