n butun soni berilgan (n>0). Uni bo‘lib butun va qoldiq
qismlarini aniqlash orqali, berilgan son raqamlarini teskari
tartibda chiqaruvchi dastur tuzing.
import math;
n=int(input('n='));
while n>0:
i=n%10;
n=math.floor(n/10);
print(i, end='');
Doiraning elementlari quyidagi tartibda nomerlangan. 1-radius
, 2- diametr , 3-uzunligi , 4-doiraning yuzasi . Shu
formulalardan bittasi berilganda qolganlarini topuvchi dastur
tuzing
.
import math;
r=float(input('Doiraning radiusini kiriting:'));
k=float(input('Doiraning element raqamini kiriting:'));
if k==1:
print("Radius",r,"ga teng!");
elif k==2:
D=2*r;
print("Diametr",D,"ga teng!");
elif k==3:
L=2*math.pi*r;
print("Aylana uzunligi",L,"ga teng!");
elif k==4:
S=math.pi*pow(r,2);
print("Doiraning yuzi",S,'ga teng!');
Agar kvadratning tomoni A, doiraning radiusi R ga teng bo‘lsa,
kvadrat va doiraning yuzlarini solishtirib kattasini aniqlang.
Yechish. Kvadratning yuzi , doiraning yuzi formula yordamida
aniqlanadi. 2 a s 2 r k
import math
A=float(input('Kvadratning tomoni\nA='))
R=float(input('Doiraning radiusi\nR='))
S=pow(A,2)
C=math.pi*pow(R,2)
if S>C:
print("Kvadratning yuzi katta")
else:
print("Doiraning yuzi katta")
. import math
n=int(input('n='));
s=0;
for i in range(1,n+1):
s=s+math.pow(i,2);
print('S=',s)
Ihtiyoriy sonning darajasini hisoblovchi Daraja2 nomli
funksiya hosil qiling. Daraja2 funksiyasi orqali a, b, c
sonlarining darajasini hisoblovchi dastur tuzing.
def Daraja2(a):
a=a*a;
return a;
a=int(input('a='));
b=int(input('b='));
c=int(input('c='));
print("a sonning darajasi=",Daraja2(a));
print("b sonning darajasi=",Daraja2(b));
print("c sonning darajasi=",Daraja2(c));
Do'stlaringiz bilan baham: |