Python Programming
June 7, 2025 at 06:13 PM
Today, Let’s move on to the next topic in the Python Coding Challenge: 🔹 *Day 7: Loops in Python (for and while)* Loops are one of the most powerful tools in programming. They help us repeat tasks without writing repetitive code. 🔁 *for Loop* Use a for loop when you know how many times you want to repeat something. ```for i in range(5): print(i)``` 🟢 *Output* : 0 1 2 3 4 ✅ range(5) creates a sequence from 0 to 4 ✅ i takes each value one by one 🔁 *while Loop* Use a while loop when you want to repeat until a condition is no longer true. ```count = 1 while count <= 5: print(count) count += 1``` 🟢 *Output* : 1 2 3 4 5 🔨 *Mini Projects to Practice* *1. Multiplication Table Generator* ```num = int(input("Enter a number: ")) for i in range(1, 11): print(f"{num} x {i} = {num * i}")``` 👉 *This lets users generate the multiplication table of any number.* *2. Pattern Printer (Staircase of Stars)* ```rows = 5 for i in range(1, rows + 1): print("*" * i)``` 🟢 *Output:* * ** *** **** ***** 👉 *Great intro to nested logic and string multiplication.* *React with ❤️ once you’re ready for the quiz* Python Coding Challenge: https://whatsapp.com/channel/0029VaiM08SDuMRaGKd9Wv0L/1661
❤️ 👍 🇮🇳 🙏 🖕 🇵🇸 😂 😮 😢 1.0K

Comments