Dragona_Pro

๐Ÿ”ฐ Introduction :

The current image has no alternative text. The file name is: IMG_20250722_015811_edit_55078523238469-1-scaled.jpg

In programming, we often need to repeat the same code multiple times. For example:

Printing numbers from 1 to 10.

Checking elements in a list.

Repealing a game until the player loses.

Instead of manually repeating the code, we use for and while loops.

๐ŸŒ€ First: The for loop

โœ… General form :

Python

for a variable in an array:

# Iterate code

๐Ÿ“ฆ The most famous example โ€“ using range():

Python

for i in range(5):

print(i)

๐Ÿ“Œ Result :

0

1

2

3

4

๐Ÿ”Ž range(5) means: from 0 to 4 (5 not included).

๐Ÿ” Printing numbers from 1 to 10 :

Python

for i in range(1, 11):

print(i)

๐Ÿช„ Simple exercise :

Write code that prints the sentence “Hello!” Five times:

Python

for i in range(5):

print(“Hello!”)

๐Ÿงฎ Practical example: Multiplication table

Python

number = int(input(“Pick a number: “))

for i in range(1, 11):

print(number, “x”, i, “=”, number * i)

๐Ÿ”„ Second: The while loop

โœ… General form :

Python

while condition:

# code that repeats

๐Ÿ“Œ The while is used when you don’t know the number of iterations in advance.

โณ Simple example :

Python

i = 1

while i <= 5:

print(“Repeat number”, i)

i += 1

โš ๏ธ Important warning :

Beware of infinite loops! If you forget to update the condition inside the while statement, it will run forever:

python

# This code will not stop!

while True:

print(“Always on”)

๐Ÿงช Exercise 1 :

Ask the user for a password, and repeat the request until they type it correctly:

python

password = “”

while password != “python123”:

password = input(“Enter password: “)

print(“Login successful!”)

๐Ÿ” Exercise 2 :

Write code that asks the user for a number, then prints from 1 up to that number:

python

n = int(input(“Enter a number: “))

for i in range(1, n + 1):

print(i)

๐Ÿ”„ The difference between for and while

The for loop property while loop

The number of iterations is known Yes No Always

Usage: Lists, range(), defined iterations, conditional conditions, loops of unknown duration

๐Ÿ“ Summary :

You have learned to use for and while to repeat commands.

You have understood the difference between loops.

I used range() and tried practical examples.

๐Ÿ“Œ What will we learn in Lesson 5 ?

In the next lesson, we’ll learn how to organize code using functions. You’ll be able to reuse code in a smarter, more professional way.

ูƒูŠููŠุฉ ุชู†ุฒูŠู„ ุงู„ุชุทุจูŠู‚ุงุช
ุงู†ู‚ุฑ ููŠ ุงู„ุฃุณูู„ ุนู„ู‰ ุชู†ุฒูŠู„ Dragon_Pro
ุณุชุธู‡ุฑ ุตูุญุฉ ุงู„ุนุฏ ุงู„ุชู†ุงุฒู„ูŠ ุจุนุฏ ุงู„ุงู†ู‡ุงุก ู…ู† ุงู„ุนุฏ ุงู†ู‚ุฑ ุนู„ู‰ ุชุญู…ูŠู„ ุงู„ุงู†
ุซู… ููŠ ุงู„ุงุณูู„ ุงู†ู‚ุฑ ุนู„ู‰ ุชุญู…ูŠู„ ุนุงุฏูŠ
ุงู†ุชุถุฑ ุญุชู‰ ูŠู†ุชู‡ูŠ ุงู„ุนุฏ ู…ุฑุฉ ุงุฎุฑู‰
ุณุชุธู‡ุฑ ุงูŠู‚ูˆู†ุฉ ุงุจุฏุง ุชุญู…ูŠู„ ุงู„ุงู†
ุงู†ู‚ุฑ ุนู„ูŠู‡ุง ุณูŠุชู… ุชุญู…ูŠู„ ุงู„ุชุทุจูŠู‚

How to download apps Click Download Dragon_Pro

at the bottom.
A countdown page will appear. After the countdown is complete, click Download Now. Then at the bottom, click Normal Download.
Wait for the countdown to finish again Then the Start Download Now icon will appear.
Click it to download the app.

โฌ‡๏ธ Download Dragona_Pro ุชุญู…ูŠู„

Related Posts

Rapid_tv

๐Ÿ”น Introduction The Rock, Paper, Scissors Game is a classic hand game that you can easily build in Python. ๐Ÿ‘‰ Rules: ๐Ÿ”น Code Example ๐Ÿ”น Example Run ๐Ÿ”น Concepts Learned…

Read more

VOD-ZalHD

๐Ÿ”น Introduction The Number Guessing Game is a classic beginner Python project. ๐Ÿ”น Code Example ๐Ÿ”น Example Run ๐Ÿ”น Concepts Learned ๐Ÿ”น Summary โฌ‡๏ธ Download VOD-ZalHD ุชุญู…ูŠู„ Server 1 โฌ‡๏ธ…

Read more

Delux_pro

๐Ÿ”น Introduction The To-Do List App is one of the most popular beginner projects. It teaches you how to: ๐Ÿ”น Code Example ๐Ÿ”น Features of This App ๐Ÿ”น Example Run…

Read more

Fam4k

๐Ÿ”ฐ Project Overview A calculator is one of the simplest yet most effective projects to start with in Python.You will learn: โœ๏ธ Step 1: Plan the Calculator We need: ๐Ÿ–ฅ๏ธ…

Read more

Speed_HD+

1. Introduction Data visualization helps us understand patterns and insights in data by converting raw numbers into charts and graphs.In Python, the most popular libraries are: 2. Installing Required Libraries…

Read more

Dauo

1. Introduction Web scraping is the process of extracting data from websites. In Python, we commonly use libraries like requests (to fetch web pages) and BeautifulSoup (to parse and extract…

Read more