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


the good work going every day, (magician.title()}. \n”)



Download 2,02 Mb.
Pdf ko'rish
bet52/126
Sana01.01.2022
Hajmi2,02 Mb.
#285662
1   ...   48   49   50   51   52   53   54   55   ...   126
Bog'liq
Learning Python The Ultimate Guide for Beginners to Coding with

the good work going every day, (magician.title()}. \n”)
magicians_names =[“Greg,” “Perpetual,” “Amos”]
for magician in magicians_names:
print(f “{magician.title()}, you did an excellent trick today!”)
print(f “Keep the good work going every day, (magician.title()}. \n”)
The  line  in  bold  and  italicize  should  have  been  indented,  but  the  interpreter  finds  at  least  a
statement  indented  after  the  “for  magician  in  magicians_name”  a  statement.  However,  it  doesn’t
indicate  any  error;  when  the  first  print()  method  takes  action  for  each  name  contained  in  our
magician  list,  it  prints  the  same  message  to  the  names.  However,  for  the  second  print()  method,
because it is not indented, it executes the loop once before halting the program. Among the three


magicians  (Greg,  Perpetual,  and  Amos),  only  Amos  will  receive  the  message,  “Keep  the  good
work going every day.” The output of this program will be as follow:
Greg, you did an excellent trick today!
Perpetual, you did an excellent trick today!
Amos, you did an excellent trick today!
Keep the good work going every day
This  error  is  also  known  as  a  logical  error  because  the  syntax  is  an  acceptable  Python  code.
However,  it  doesn’t  produce  the  result  we  expected  because  of  the  logic  error  in  the  code.
Therefore, if your goal is to repeat a certain code once for every item in a list, then you can do that
with indentation.

Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   48   49   50   51   52   53   54   55   ...   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