Pythonda takrorlanuvchi algoritmlar bilan ishlash


Agar kvadratning tomoni A, doiraning radiusi R ga teng bo‘lsa, kvadrat va doiraning yuzlarini solishtirib kattasini aniqlang


Download 38.89 Kb.
bet8/9
Sana31.01.2023
Hajmi38.89 Kb.
#1145125
1   2   3   4   5   6   7   8   9
Bog'liq
nazariy savollarga javob

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));

Ikkita sonning o‘rta arifmetigi va geometrigini hisoblovchi o‘rta_arifmetigi_geometrigi nomli funksiya hosil qiling. o‘rta_arifmetigi_geometrigi funksiyasi orqali a, b, c, d sonlaridan (a, b), (a, c), (a, d) juftliklarining o‘rta arifmetigi va geometrigini hisoblovchi dastur tuzing. import math;
def orta_arifmetigi_geometrigi(a,b):
p=math.sqrt(a*b);
s=(a+b)/2;
print("O'rta geometrigi=",p);
print("O'rta arifmetigi=",s);
a=int(input('a='));
b=int(input('b='));
c=int(input('c='));
d=int(input('d='));
orta_arifmetigi_geometrigi(a,b);
orta_arifmetigi_geometrigi(a,c);
orta_arifmetigi_geometrigi(a,d);


Download 38.89 Kb.

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




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