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



Download 2,02 Mb.
Pdf ko'rish
bet62/126
Sana01.01.2022
Hajmi2,02 Mb.
#285662
1   ...   58   59   60   61   62   63   64   65   ...   126
Bog'liq
Learning Python The Ultimate Guide for Beginners to Coding with

Using loop in a Tuple
Similar to what we did in a list using the “for loop,” tuple allows us to loop through the elements in
it. For instance,
sizes =(200, 100)
for size in sizes:
print(size)
The output will be:
200
100
Writing Through a Tuple
As already stated, you cannot modify or alter a tuple; however, you can allocate new values to the
variable representing the tuple. Assuming something happens and you decide to change the size of
the room, you can redefine the entire tuple.
sizes =(200, 100)
print(“This is our original room size:”
for size in sizes:
print(size)


sizes = (300, 150)
print(“Our new room size:”)
for size in sizes
print(size)
The output will be as follows:
This is our original room size:
200
100
Our new room size:
300
150
Summary
So far, in this chapter, you have learned everything you need to know as it concerns lists and tuple.
I am convinced that you can efficiently work with elements in a list. We also went through how to
use  a  “for  loop”  in  a  list,  the  structure  of  indenting  a  Python  program,  and  popular  indentation
errors to avoid. You learned how to make numerical lists and perform certain operations such as
finding the maximum, minimum, and sum in a list. Additionally, we learned more about slicing a
list and getting only the details you want in a list.
Finally, you learned about tuples. You also know what makes it different from a list. The values of
a tuple cannot change, whereas that of a list can be changed in the course of the program. In the
next  chapter,  you  will  learn  about  using  various  conditional  statements  in  Python.  Endeavor  to
practice the exercise provided in this chapter, as it will enhance your programming skills in Python.
If  peradventure  you  encounter  an  error,  take  your  time  to  go  through  the  line  indicated.
Congratulations on your promotion to the next chapter of this course.



Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   58   59   60   61   62   63   64   65   ...   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