0% found this document useful (0 votes)
12 views4 pages

Python Functions Lesson Plan

This lesson plan introduces students to functions in Python, covering their definition, usage, parameters, and return values. Students will engage in discussions, demonstrations, and hands-on activities to write and apply functions for various tasks. The lesson concludes with a verbal quiz and a take-home project to reinforce learning.

Uploaded by

lethanhthai0805
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Python Functions Lesson Plan

This lesson plan introduces students to functions in Python, covering their definition, usage, parameters, and return values. Students will engage in discussions, demonstrations, and hands-on activities to write and apply functions for various tasks. The lesson concludes with a verbal quiz and a take-home project to reinforce learning.

Uploaded by

lethanhthai0805
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Lesson Plan: Introduction to Functions in PythonDuration: 60

minutes

Objective:

By the end of this lesson, students will be able to:

 Understand what functions are and why they are useful.

 Define and call functions in Python.

 Use function parameters and return values.

 Apply functions to solve simple problems.

1. Warm-Up (10 minutes)

Discussion:

 Ask students: "Why do we use functions in real life?" (e.g., making a


sandwich, brushing teeth – repetitive tasks)

 Explain that in programming, functions help us avoid repetition,


organize code, and make debugging easier.

Quick Example:

Show a simple program without functions:

print("Hello, Alice!")

print("Hello, Bob!")

print("Hello, Charlie!")

Then, show the same code using a function:

def greet(name):

print("Hello, " + name + "!")

greet("Alice")

greet("Bob")

greet("Charlie")

Ask students: Which version is better? Why?

2. Explanation & Demonstration (15 minutes)


1. Defining Functions

 Explain function syntax:

def function_name(parameters):

# Code block (indentation is required)

return value # (Optional)

 Example of a basic function:

def say_hello():

print("Hello, world!")

say_hello() # Calling the function

2. Function Parameters

 Example of a function with parameters:

def greet(name):

print(f"Hello, {name}!")

greet("Alice")

greet("Bob")

3. Return Values

 Explain why return values are important.

 Example:

def add(a, b):

return a + b

result = add(5, 3)

print(result) # Output: 8

4. Multiple Parameters

 Example:

def multiply(a, b):

return a * b
print(multiply(4, 5)) # Output: 20

3. Hands-on Practice (20 minutes)

Activity 1: Write a Function

 Ask students to write a function square(num) that returns the


square of a number.

def square(num):

return num * num

print(square(4)) # Output: 16

print(square(7)) # Output: 49

Activity 2: Create a Custom Greeting

 Ask students to write a function custom_greet(name, time_of_day)


that prints a personalized message.

def custom_greet(name, time_of_day):

print(f"Good {time_of_day}, {name}!")

custom_greet("Alice", "morning")

custom_greet("Bob", "afternoon")

Activity 3: Simple Calculator

 Ask students to write a function calculate(num1, num2, operation)


that performs addition or multiplication.

def calculate(num1, num2, operation):

if operation == "add":

return num1 + num2

elif operation == "multiply":

return num1 * num2

else:

return "Invalid operation"


print(calculate(3, 5, "add")) # Output: 8

print(calculate(4, 6, "multiply")) # Output: 24

4. Assessment & Wrap-up (15 minutes)

Concept Check (Verbal Quiz)

1. What is the purpose of a function?

2. What is the difference between a function with and without a


parameter?

3. What does the return keyword do?

4. What happens if you don’t call a function?

Mini Project (Take-home Assignment)

 Ask students to create a function convert_temperature(celsius)


that converts Celsius to Fahrenheit.

def convert_temperature(celsius):

return (celsius * 9/5) + 32

print(convert_temperature(0)) # Output: 32°F

print(convert_temperature(100)) # Output: 212°F

Wrap-up Discussion

 Ask students how functions can be useful in real-world applications


(e.g., games, apps, data science).

 Give a preview of the next lesson (e.g., functions with default


parameters, recursion, or lambda functions).

You might also like