masaladan tuple dan 10 bilan 50 ni chiqazish kerak:
tuple = (10, 20, 30, 40, 50)
print(tuple)
print(tuple[0::4])
masalada 3 ta son yaratib olib ularni n1, n2, n3 larga tenglashtirib qo'shish kerak keyin javobini ekrangga chiqarish kerak:
tuple = (150, 250, 350)
print(tuple)
n1, n2, n3 = tuple
print(n1 + n2 + n3)
tuple ga 8ta sonni tenglashtirish kerak va ularni oldiga yana ikkita sonni qo'shib yozish kerak:
tuple = (5, 6, 7, 6, 9, 1, 2, 3)
print(tuple)
tuple = tuple + (10, 200, )
print(tuple)
varibles yaratib olamiz va unga nechtadir sonni tenglaymiz va "revers" funksiyasi bilan 500 dan 100gacha chiqadi
list1 = [100, 200, 300, 400, 500]
list1.reverse()
print(list1)
ikkalasi ikkita masala lekin bir xil
list1 = (300, 400, 500, 600, 700)
list1 = list1[::-1]
print(list1)
bunda 1 slaydni 1 sonini chiqarish kerak
tuple = ("orange",[10, 20, 30],(5, 15, 25))
print(tuple)
print(tuple[1])
print(tuple[1][1])
bunda 6 ta raqamni bitta variblesga teglashtib olish kerak va 2ch varibles ni 1chi veribles ga tenglashtirib olib undan 3 va 4 slaydni chiqazib 3chi slayddan 0chi slaydgacha chiqazish kerak
tuple1 = (11, 22, 33, 44, 55, 66)
tuple2 = tuple1
print(tuple2[3])
print(tuple2[4])
tuple1 = tuple2[3::-1]
print(tuple1)
Chop etish "yes" agar funksiyasi true qiymatini qaytarsa, aks holda "NO" ni chop eting
def myFunction() :
return True
if myFunction():
print("yes")
else:
print("no")
pasword to'g'ri yoki noto'g'ri ekanligini tekshiring
password = input("Enter pasword")
if password == "1549":
print("Correct password")
else:
print("Incorrect password")
ikkita son kiriting va 1chi son 2chi sondan katta bo'lsa "true"chiqsin aks holda "False"
password = input("Enter pasword")
if password == "1549":
print("true")
else:
print("False")
Top comments (0)