Algorithms For Dummies


DisplayMulti('Hello', 'Cont', 'Goodbye', 'Break', 'Last')



Download 7,18 Mb.
Pdf ko'rish
bet177/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   173   174   175   176   177   178   179   180   ...   651
Bog'liq
Algorithms

DisplayMulti('Hello', 'Cont', 'Goodbye', 'Break', 'Last') and press Enter. Notice 

that the words 

Cont

 and 


Break

 don’t appear in the output because they’re key-

words. In addition, the word 

Last


 doesn’t appear in the output because the 

for


 

loop ends before this word is processed.



Using the while statement

The 


while

 loop statement continues to perform tasks until such time that a con-

dition is no longer true. As with the 

for


 statement, the 

while


 statement supports 

both the 

continue

 and 


break

 keywords for ending the loop prematurely. To see 

how this works, open a copy of IPython and type the following code:

def SecretNumber():

   GotIt = False

   while GotIt == False:

      One = int(input("Type a number between 1 and 10: "))

      Two = int(input("Type a number between 1 and 10: "))

  

      if (One >= 1) and (One <= 10):



         if (Two >= 1) and (Two <= 10):

            print('Secret number is: ' 

+ str(One * Two))

            GotIt = True

            continue

         else:

            print("Incorrect second value!")

      else:

         print("Incorrect first value!")

      print("Try again!")




CHAPTER 4


Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   173   174   175   176   177   178   179   180   ...   651




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
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