-


x = [154,634,892,345,341,43]



Download 9,79 Mb.
Pdf ko'rish
bet33/64
Sana16.01.2022
Hajmi9,79 Mb.
#372467
1   ...   29   30   31   32   33   34   35   36   ...   64
Bog'liq
[Nichola Lacey] Python by Example Learning to Pro(1)

x = [154,634,892,345,341,43] 
Here we have created a list that contains 
numbers. 
Please note:
 
as it contains numeric 
data, no speech marks are required. 
print(x[1:4]) 
This will display data in positions 1, 2 and 3. In 
this case 634, 892 and 345. Remember, Python 
starts counting from 0 and will stop when it gets 
to the last position, without showing the final 
value. 
print(len(x)) 
Displays the length of the list 
(i.e. how many items are in the 
list). 
num = int(input(“Enter number: ”)) 
if num in x: 
 print(num,“is in the list”) 
else: 
 print(“Not in the list”) 
Asks the user to enter a number and checks 
whether the number is in the list and displays an 
appropriate message. 
for i in x: 
 print(i) 
Uses the items in the list in a for 
loop, useful if you want to print 
the items in a list on separate 
lines. 

Download 9,79 Mb.

Do'stlaringiz bilan baham:
1   ...   29   30   31   32   33   34   35   36   ...   64




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