-


for loop  allows Python to keep repeating code a set number of times. It is sometimes  known as a  counting loop



Download 9,79 Mb.
Pdf ko'rish
bet21/64
Sana16.01.2022
Hajmi9,79 Mb.
#372467
1   ...   17   18   19   20   21   22   23   24   ...   64
Bog'liq
[Nichola Lacey] Python by Example Learning to Pro(1)

for loop
 allows Python to keep repeating code a set number of times. It is sometimes 
known as a 
counting loop
 because you know the number of times the loop will run 
before it starts.  
 
In this case, it starts at 1 and will keep repeating the loop 
(displaying i) until it reaches 10 and then stops. This is how this 
loop would look in Python 
 
In this example, the outputs would be 1, 2, 3, 4, 5, 6, 7, 8 and 9. 
When it gets to 10 the loop would stop so 10 would 
not be shown in the output.
 
R
Remember to indent the lines  
of code within the for loop. 


336 
 
Challenges 35 - 44: For Loop 
 
 
Example Code 
The range function is often used in for loops and lists the starting number, the ending 
number and can also include the steps (e.g. counting in 1s, 5s or any other value you wish). 
 
 
 
 
 
 
 
 
 
  

Download 9,79 Mb.

Do'stlaringiz bilan baham:
1   ...   17   18   19   20   21   22   23   24   ...   64




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish