Learning Python: The Ultimate Guide for Beginners to Coding with Python with Useful Tools


Note: Always remember to save your programs



Download 2,02 Mb.
Pdf ko'rish
bet47/126
Sana01.01.2022
Hajmi2,02 Mb.
#285662
1   ...   43   44   45   46   47   48   49   50   ...   126
Bog'liq
Learning Python The Ultimate Guide for Beginners to Coding with

Note: Always remember to save your programs.
Looping in Python
The  theory  of  looping  is  significant  in  any  programming  language,  including  Python,  because  it
provides an easier way for a computer to perform automatic repetitive tasks. For instance, in our
previous  magician  program,  in  the  second  line,  the  interpreter  reads  the  line  (magician  in
magicians_name). The line informs the interpreter to retrieve the first value of the magicians_name
list. It further assigns it to the variable magician. The first value is “Greg,” and the interpreter goes
to read the next line – print(magician) .
The  interpreter  goes  back  to  the  second  line  and  retrieves  the  second  name  “Perpetual”  before
assigning  it  to  the  variable  magician.  Then  the  last  line  is  executed,  which  prints  the  name
“Perpetual.” Once this is completed, the interpreter repeats the loop again to evaluate the last value
and print “Amos.” Since that is the last loop, there is no more instruction to execute, the program
halts. In the course of using a loop in Python, remember that the steps are repeated once for each
element in the list, irrespective of the number of elements in the list you created. Additionally, you
have the liberty to select the name you desire to store your values in the program. However, it is
important to use a meaningful name. For instance, let us use a list of lions, horses, and cars.
for lion in lions
for horse in horses
for car in cars
This kind of naming convention will enable you to follow the actions performed on each item in
the loop. You can also identify the section of the code with errors when you use singular and plural
names.



Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   43   44   45   46   47   48   49   50   ...   126




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