| aidemia--modules-lessonplan_request | Titles of parts of the lesson must be formatted as headings |
| What to create | Lesson plan |
| Which subject | Computer science |
| What topic | Δομή Επανάληψης ΑΕΠ |
| What length (min) | 30 |
| What age group | College |
| Include homework | |
| Include images descriptions | |
| Any other preferences |
Computer Science
30 minutes
By the end of this lesson, students will be able to understand and apply iteration structures in programming, specifically focusing on loops (for, while, and do-while) and their usage in algorithm development.
for i in range(1, 11):
print(i)
i = 1
while i <= 10:
print(i)
i += 1
i = 1
while True:
print(i)
i += 1
if i > 10:
break
for loop that calculates the factorial of a given number.while loop that prints all even numbers from 1 to 50.do-while loop program that asks a user for a number and keeps asking until they enter a negative number.Factorial using For Loop:
number = int(input("Enter a number: "))
factorial = 1
for i in range(1, number + 1):
factorial *= i
print("Factorial:", factorial)
Even Numbers using While Loop:
i = 1
while i <= 50:
if i % 2 == 0:
print(i)
i += 1
Do-While Loop Example (Python does not have a do-while structure, simulate it):
while True:
num = int(input("Enter a number (negative to quit): "))
if num < 0:
break
Encourage students to explore different problems and implement various iteration structures to find the most efficient solutions. Reinforce the importance of understanding loops in programming and software development.