Uploaded by Name Surname

Pythonda boshlangich amallar

advertisement
Laboratoriya 1
1.
O’zgaruvchi e’lon qiling va uni ekranga chop eting.
uzgaruvchi = "Salom Python"
print(uzgaruvchi)
2 Matn yarating va uning uzunligini ekranda chop eting.
matn = "Salom dunyo"
print(len(uzgaruvchi))
3 Shart operatorlari yordamida berilgan son juft yoki toqligini tekshiring.
son = 5
if son % 2 == 0:
print("Juft son")
else:
print("Toq son")
4 Ro’yxat yarating va maxsus metodlar yordamida uni
a. tartiblang
b. aylantiring
c. qo’shimcha element qo’shing
d. uzunligini ekranga chiqaring
ruyxat = [22, 2, 6, 7, 4, 11, 32, 66, 8, 99, 65]
ruyxat.sort()
print(ruyxat)
ruyxat.reverse()
print(ruyxat)
ruyxat.append(23)
print(ruyxat)
print(len(ruyxat))
5. Berilgan ro’yxatning elementlarini ekranga chop eting va yig’indisini hisoblang
yigindi = 0
for element in ruyxat:
print(element)
yigindi += element
print(yigindi)
6. Lug’at yarating va uning kalit so’zlarini ekranda chop eting
noutbuk = {'brend': "HP", 'rangi': 'qora', 'tezkorXotira': 16}
for key in noutbuk.keys():
print(key)
Download