LAB10

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

LAB10

November 17, 2021

[10]: #1. khuns = ("Baitsaa", "Guril", "Luuvan", "makh", "Sarmis", "Majin",␣


,→"Ulaanlooli")

khuns = ("Baitsaa", "Guril", "Luuvan", "makh", "Sarmis", "Majin", "Ulaanlooli")


print(khuns[0], khuns[2], khuns[4:6])

Baitsaa Luuvan ('Sarmis', 'Majin')

[11]: #2. tup1 = (1,2,3,4,5,6,7,8,9) �������� ��������� ������� ����� ���� ��� ��� ������� ������ ��� ����� ��!
tup1 = (1,2,3,4,5,6,7,8,9)
s=0
f=0
for i in range(len(tup1)):
if tup1[i]%2==0:
s=s+1
else:
f=f+1
print("Niit tegsh too: ", s)
print("Niit sondgoi too: ", f)

Niit tegsh too: 4


Niit sondgoi too: 5

[3]: #3. Tup1,Tup2 = (1,2,3,4,5,6,7,8,9),(22,14,89,23,9,10) ������� �� ����� ������� ���� ����������␣


,→��� ����� ���� tup3 �����.

Tup1,tup2 = (1,2,3,4,5,6,7,8,9),(22,14,89,23,9,10)
max = Tup1[0]
min = Tup1[0]
for i in range(len(Tup1)):
if Tup1[i]>max:
max = Tup1[i]
if Tup1[i]<min:
min = Tup1[i]
s = min + max
max = tup2[0]
min = tup2[0]
for i in range(len(tup2)):
if tup2[i]>max:
max = tup2[i]

1
if tup2[i]<min:
min = tup2[i]
f = min + max
tup3 = (s, f)
print(tup3)

(10, 98)

[4]: #4. Tup1, tup2-��� ������ ����� �����.


Tup1,tup2 = (1,2,3,4,5,6,7,8,9),(22,14,89,23,9,10)
x = list(Tup1)
y = list(tup2)
for i in range(len(Tup1)):
for j in range(len(tup2)):
if Tup1[i] == tup2[j]:
x.remove(Tup1[i])
y.remove(tup2[j])
Tup1 = tuple(x)
tup2 = tuple(y)

print(Tup1)
print(tup2)

(1, 2, 3, 4, 5, 6, 7, 8)
(22, 14, 89, 23, 10)

[5]: #5. ����� �������� ������ �������������� ���� ���� ������� ��


mobile1 = {"brand": "Apple","mark": "Iphone 12","year": 2021}
mobile2 = {"brand": "Samsung","mark": "Galaxy s21","year": 2021}
mobile3 = {"brand": "OnePlus","mark": "9 Pro","year": 2021}
mobile4 = {"brand": "Google","mark": "Pixel 5","year": 2021}
mobile5 = {"brand": "Samsung","mark": "Z fold 2","year": 2021}
print(mobile1)
print(mobile2)
print(mobile3)
print(mobile4)
print(mobile5)

{'brand': 'Apple', 'mark': 'Iphone 12', 'year': 2021}


{'brand': 'Samsung', 'mark': 'Galaxy s21', 'year': 2021}
{'brand': 'OnePlus', 'mark': '9 Pro', 'year': 2021}
{'brand': 'Google', 'mark': 'Pixel 5', 'year': 2021}
{'brand': 'Samsung', 'mark': 'Z fold 2', 'year': 2021}

[6]: #6. �������� 5 �������� ������ ������� ��������� ���� ������� ��.
mobile1 = {"brand": "Apple","mark": "Iphone 12","year": 2021}
mobile2 = {"brand": "Samsung","mark": "Galaxy s21","year": 2021}
mobile3 = {"brand": "OnePlus","mark": "9 Pro","year": 2021}
mobile4 = {"brand": "Google","mark": "Pixel 5","year": 2021}

2
mobile5 = {"brand": "Samsung","mark": "Z fold 2","year": 2021}
x = mobile1.keys()
print(x)

dict_keys(['brand', 'mark', 'year'])

[7]: #7. �������� 5 �������� ������ ������������� ���� �����


mobile1 = {"brand": "Apple","mark": "Iphone 12","year": 2021}
mobile2 = {"brand": "Samsung","mark": "Galaxy s21","year": 2021}
mobile3 = {"brand": "OnePlus","mark": "9 Pro","year": 2021}
mobile4 = {"brand": "Google","mark": "Pixel 5","year": 2021}
mobile5 = {"brand": "Samsung","mark": "Z fold 2","year": 2021}
s = 0
for x in mobile1.values():
s = s + 1
print(s*5)

15

[8]: #8. �������� 5 �������� ������ ������� ����


mobile1 = {"brand": "Apple","mark": "Iphone 12","year": 2021}
mobile2 = {"brand": "Samsung","mark": "Galaxy s21","year": 2021}
mobile3 = {"brand": "OnePlus","mark": "9 Pro","year": 2021}
mobile4 = {"brand": "Google","mark": "Pixel 5","year": 2021}
mobile5 = {"brand": "Samsung","mark": "Z fold 2","year": 2021}
mobile1["mark"] = "hulan21"
mobile2["mark"] = "hulan21"
mobile3["mark"] = "hulan21"
mobile4["mark"] = "hulan21"
mobile5["mark"] = "hulan21"
print(mobile1)
print(mobile2)
print(mobile3)
print(mobile4)
print(mobile5)

{'brand': 'Apple', 'mark': 'hulan21', 'year': 2021}


{'brand': 'Samsung', 'mark': 'hulan21', 'year': 2021}
{'brand': 'OnePlus', 'mark': 'hulan21', 'year': 2021}
{'brand': 'Google', 'mark': 'hulan21', 'year': 2021}
{'brand': 'Samsung', 'mark': 'hulan21', 'year': 2021}

[ ]:

You might also like