🧠 Introduction
🐍 Python Day 6 – Loops (for & while)
Manam If-Else tho decisions tiskunnam.
Eroju manam loops nerchukundam.
👉 Loop ante same code ni malli malli run cheyadam
👉 Time save avutundi + automation easy
💡 Example: 1 nundi 10 varaku print cheyadam
🔁 for Loop
for i in range(1, 6):
print(i)
print(i)
👉 Output:
1 2 3 4 5
🔁 while Loop
i = 1
while i <= 5:
print(i)
i += 1
while i <= 5:
print(i)
i += 1
🧪 Example – Table Print
num = int(input("Enter number: "))
for i in range(1, 11):
print(num, "x", i, "=", num * i)
⚠️ Infinite Loop (Careful!)
while True:
print("Hello")
print("Hello")
👉 Stop cheyyali ante: Ctrl + C
🎯 Mini Practice
for i in range(1, 11):
if i % 2 == 0:
print(i)
if i % 2 == 0:
print(i)
👉 Even numbers print avutayi
📌 Summary
✔ for loop nerchukunnam
✔ while loop use chesam
✔ practical examples chusam
Comments
Post a Comment