Learn with Yasir

Learn Python, Microsoft 365 and Google Workspace

Home

Share Your Feedback

Lesson Plan: IT-323 Python Programming 3(2-1)

Week #: Control Flow Statements

Lecture #: While Loops in Python

Learning Objectives:

By the end of this lecture, students will be able to:
✅ Understand the syntax and working of the while loop in Python.
✅ Implement while loops to perform repetitive tasks based on a condition.
✅ Use while loops to solve real-world problems such as printing sequences, summing numbers, and generating multiplication tables. ✅ Apply while loops with conditional statements to control program flow.

Topics Covered:

  1. Introduction to While Loops
    • Definition and syntax of the while loop.
    • How a while loop executes based on a condition.
  2. Basic Examples
    • Printing numbers from 1 to 10 using a while loop.
    • Printing “Hello, world!” multiple times.
  3. Using While Loops in Mathematical Computations
    • Generating multiplication tables.
    • Summing integers from 1 to 100.
    • Calculating the sum of even numbers in a range.
    • Computing squares of numbers.
  4. Hands-on Activity: Basic While Loop Practice
    • Modify the given example to print numbers from 1 to 20 instead of 1 to 10.
    • Change the “Hello, world!” loop to print a user-defined number of times.
    • Modify the sum-from-1-to-100 program to sum only odd numbers from 1 to 100.

Resources:

📖 Lecture Notes 📌 Reference Book: **, Chapter

Assignments & Tasks:

📂 Examples: Work through Examples 5.18 - 5.20 from the lecture notes.
📝 Task: Complete and submit tasks 5.12 - 5.14 by the next session.