Laboratoriya 1 O’zgaruvchi e’lon qiling va uni ekranga chop eting


Download 16.32 Kb.
Sana11.02.2023
Hajmi16.32 Kb.
#1189083
Bog'liq
lab1


Laboratoriya 1



  1. O’zgaruvchi e’lon qiling va uni ekranga chop eting.

uzgaruvchi = "Salom Python"
print(uzgaruvchi)



  1. Matn yarating va uning uzunligini ekranda chop eting.

matn = "Salom dunyo"
print(len(uzgaruvchi))



  1. Shart operatorlari yordamida berilgan son juft yoki toqligini tekshiring.

son = 5
if son % 2 == 0:
print("Juft son")
else:
print("Toq son")

  1. Ro’yxat yarating va maxsus metodlar yordamida uni

    1. tartiblang

    2. aylantiring

    3. qo’shimcha element qo’shing

    4. 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 16.32 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling