#1 Ob’ekt tushunchasi yoritib bering va misollar keltiring


hayvonlar obyektini yarating? (23 ga qarang va keraklicha o’zgartiring) 25


Download 196.81 Kb.
bet11/11
Sana31.01.2023
Hajmi196.81 Kb.
#1144964
1   2   3   4   5   6   7   8   9   10   11
Bog'liq
django

24
hayvonlar obyektini yarating? (23 ga qarang va keraklicha o’zgartiring)

25
class Kitoblar:
def __init__(self, nomi, muallifi,bet):
self.nomi = nomi
self.muallifi = muallifi
self.bet = bet
def malumot(self):
print("nomi: "+ self.nomi + “, muallifi ” + self. muallifi + “, beti: “ + self.bet)
k1= Kitoblar("oshnolar", “Yulduz Komilova”, 110)
k2 = Kitoblar("g`oyam", “Najmiddin Erbaqon”, 300) #vahokazo
k1.malumot()
k2.malumot()

Natija:


nomi: oshnolar, muallifi: Yulduz Komilova, beti: 110
nomi: g`oyam, muallifi: Najmiddin Erbaqon, beti: 300

26
class Gilamlar:
def __init__(self, rang, olcham):
self.rang = rang
self. olcham = olcham
def malumot(self):
print("rangi: "+ self.rang + “, olchami ” + self. olcham)
g1= Gilamlar ("qizil", “450x750”)
k2 = Gilamlar ("yashil", “350x450”) #vahokazo
k1.malumot()
k2.malumot()

Natija:


rangi: qizil, olchami: 450x750
rangi: yashil, olchami: yashil

27
class Toshlar:
def __init__(self, nomi, narx):
self.nomi = nomi
self.narx = narx
def malumot(self):
print("nomi: "+ self.nomi + “, narxi” + self. narx)
t1= Toshlar ("Olmos",”10000$”)
t2 = Toshlar ("Yoqut", “20000$”) #vahokazo
t1.malumot()
t2.malumot()

Natija:


nomi: Olmos, narxi: 10000$
nomi: Yoqut, narxi: 20000$

28
class Smartfon:
def __init__(self, nomi, narx):
self.nomi = nomi
self.narx = narx
def malumot(self):
print("nomi: "+ self.nomi + “, narxi” + self. narx)
t1= Smartfon ("Samsung",”400$”)
t2 = Smartfon ("Redmi", “300$”) #vahokazo
t1.malumot()
t2.malumot()

Natija:


nomi: Samsung, narxi: 400$
nomi: Redmi, narxi: 300$


29
class Kompyuter:
def __init__(self, ram,rom, narx):
self. ram = ram
self. rom = rom
self.narx = narx
def malumot(self):
print("ram: "+ self.ram + ", rom: "+ self.rom + “, narxi” + self. narx)
acer= Kompyuter (4,512,”400$”)
asus = Kompyuter (8, 512,“700$”) #vahokazo
acer.malumot()
asus.malumot()

Natija:


ram: Samsung, rom: 512, narxi: 400$
ram: 8, rom: 512, narxi: 700$

Xullas qolganlari ham wunaqa kallani sal iwlat
Download 196.81 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   10   11




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