Python Programming for Biology: Bioinformatics and Beyond



Download 7,75 Mb.
Pdf ko'rish
bet51/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   47   48   49   50   51   52   53   54   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

The ‘

while

’ loop

In addition to the for loop that operates on a collection of items, there is a while loop that

simply repeats while some statement is True:

while conditionalExpression:

# codeBlock

The  codeBlock  is  repeated  over  and  over  until  the  conditionalExpression  evaluates  to

False. Note that if the tested expression never evaluates to False then you have an ‘infinite

loop’, which is naturally not helpful. Sometimes you can use a while loop to avoid having

to  initially  generate  a  collection  of  items  to  then  loop  over.  For  example,  you  could

generate a series of numbers by doubling a value at each iteration, until a limit is reached:

value = 1

while value < 32:

# maybe do something with the value

value *= 2

# value is 32 at the end

What happens here is that the value is doubled in each loop and once it gets to 32  the

while test fails (32 is not less than 32) and that last value is preserved. Note that if the test

were instead value <= 32 then we would get one more doubling and the value would reach

64.


Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   47   48   49   50   51   52   53   54   ...   514




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