0% found this document useful (0 votes)
3 views14 pages

Python_Constructs_Lesson

This document outlines a lesson on programming constructs in Python, focusing on iteration and selection using loops and conditional statements. It covers the use of `for` and `while` loops, as well as `if`, `elif`, and `else` statements with practical examples. The lesson includes objectives, exercises, and a homework assignment to reinforce learning.
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)
3 views14 pages

Python_Constructs_Lesson

This document outlines a lesson on programming constructs in Python, focusing on iteration and selection using loops and conditional statements. It covers the use of `for` and `while` loops, as well as `if`, `elif`, and `else` statements with practical examples. The lesson includes objectives, exercises, and a homework assignment to reinforce learning.
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
You are on page 1/ 14

Title Slide

• Understanding Programming Constructs in


Python
• Using Loops and Decisions Made Simple
• Instructor: [Your Name]
Lesson Objectives
• - Understand iteration and selection
• - Use `for` and `while` loops
• - Use `if`, `elif`, `else`
• - Write simple Python programs
What is Iteration?
• - Doing something again and again
• - Python uses loops:
• - `for` (known times)
• - `while` (until a condition)
The `for` Loop
• data = [5, 2, 8, 1, 9]
• for num in data:
• print(num)
Using `range()` with `for`
• for i in range(3):
• print("Keep learning Python!")
The `while` Loop
• index = 0
• while index < len(data):
• print(data[index])
• index += 1
Searching with `while`
• target = 8
• index = 0
• found = False
• while index < len(data):
• if data[index] == target:
• found = True
• break
• index += 1
• print("Found:", found)
What is Selection?
• - Choosing based on a condition
• - Use `if`, `elif`, `else`
Simple Selection Example
• age = 14
• if age >= 18:
• print("You can vote.")
• elif age >= 13:
• print("You are a teenager.")
• else:
• print("You are a child.")
Using Selection with Loops
• scores = [70, 45, 90, 60, 30]
• for score in scores:
• if score >= 50:
• print("Pass")
• else:
• print("Fail")
Group Exercise
• - Loop through ages
• - Print "Adult", "Teen", or "Child" using `if`
Recap and Q&A
• - `for`: known repetitions
• - `while`: condition-based
• - `if/else`: decisions
Homework Assignment
• - Ask for 5 numbers
• - Print “Even” or “Odd” using loops and `if`
Thank You!
• Questions?
• Let’s try writing more programs together!

You might also like