105
Pythonda dastur tuzilishi:
def katta_son(x, y):
if x>y: kat=x
else: kat=y
return kat
#dastur
tanasi
a=int(input(‘a son kiriting =’))
b=int(input(‘b son kiriting =’))
c=int(input(‘c son kiriting =’))
d=int(input(‘d son kiriting =’))
n=kata_son(a,b)
m=kata_son(c,d)
eng_katta=katta_son(n,m)
print(‘Eng katta son =’, eng_katta)
a son kiriting =5
b son kiriting =8
c son kiriting =42
d son kiriting =16
Eng katta son 42
3 topshiriq.
Berilgan a (haqiqiy) sonining k (butun) darajasini topuvchi dastur
tuzing. Buning uchun daraja (a, k)
funksiyasini yarating
Masalaning qo’yilishi. Ixtiyoriy haqiqiy sonni butun
darajasini topish uchun
funksiya tuzamiz va bu funksiyaga qiymat berib
echimni topamiz
Pythonda dastur tuzilishi:
def daraj(x, y):
nat=x**y
return nat
a=float(input(‘a soniniga qiymat kiriting =’))
k=float(input(‘k soniniga qiymat kiriting =’))
natija=daraj(a,k)
print(“Berilgan sonning darjasi =”, natija)
a
soniniga qiymat kiriting
=5.5
k ning qiymatini kiriting =2
Berilgan sonning darjasi =
30.25