Hurmatli o`quvchi! Ushbu


Download 245.11 Kb.
Sana08.01.2022
Hajmi245.11 Kb.
#252273
Bog'liq
9-IHT Python dasturlari



Hurmatli o`quvchi! Ushbu masalalarni yechishda dasturlar bir oz original bo`lmasligi tabiiy, chunki men ham PYTHON dasturlash tilini endi o`rganmoqdaman. Agar sizga ma’qul kelmasa tanqidiy fikr bildirmang dars davomida o`zgarishlarni o`quvchilarim yordamida dasturlarni ratsionallashtirib boramiz bundagi dasturlar asosan 9-sinf o`quvchisi o`sha darsgacha bilimga ega ekanligini hisobga olinglar. Bu qo`llanmani tayyorlashda yaqindan yordam bergan @baliqchi10 telegram kanali a’zolariga ayniqsa Isomiddin Ismoilov, Sunnatullo Sultonmurodov, Dauletbay Kaipbayevlarga aloxida minnadorchilik bildiraman.67-68-dars mashqlarini o`zlarinng qoldiraman. Hurmat bilan Baliqchi tumani 10-umumiy o`rta ta’limmaktabi informatika fani o`qituvchisi Marufjon Raxmanov
#28-dars masalalari

#1. Darvozaning eni 4 metr, bo‘yi esa 3 metr:

#1) darvoza yuzasi (S)ni hisoblash dasturini tuzing;

#2) darvoza qirrasining uzunligi (P)ni hisoblash dasturini tuzing. e=4#m

b=3#m #1)

S=e*b


print('S=',S,'mert kadrat') #2)

P=2*(e+b) print('P=',P,'metr')


#2.Ikkita qayiq turg‘un suvda bir-biriga tomon 4 km/soat va

#2 km/soat tezlik bilan suzmoqda. Ular orasidagi masofa 24 km bo‘lsa: #1) ular qancha vaqtdan keyin uchrashadi?

#2) qancha vaqtdan keyin ular orasidagi masofa 12 km ni tashkil etadi? v1=4 #km/soat

v2=2 #km/soat S=24 #km

v=v1+v2

#1) S=v*t. t=S/v. v=v1+v2


t=S/v

print('t=',t,' soat') #2) S1=24-12=12 km S1=12 #km

t1=S1/v print('t1=',t1,'soat')
#3.Doiraning radiusi 4 metrga teng (PI=3.14): #1)doira yuzini hisoblang;

#2)aylana uzunligini hisoblang. #1)

pi=3.14 #s=pi*r*r r=4 #metr s=pi*r*r

print('s=',s,'metr kvadrat') #2) l=2*pi*r

l=2*pi*r print('l=',l,'metr')
# 30 dars masalalari

#1.Darvozaning eni va bo‘yi foydalanuvchi tomonidan kiritiladi #1)darvoza yuzasini hisoblash dasturini tuzing;

#2)darvoza qirrasining uzunligini hisoblash dasturini tuzing.
a=int(input('Bo`yi = ')) b=int(input('Eni= ')) #1)

#S=a*b #print('S=',S)


#2)

P=2*(a+b) print('P=',P)


#2.Quyidagi o‘zgaruvchilar turini aniqlang: #alfa = 8764; beta = ‘Lola’ son=30.2

#alfa=8764 #print(type(alfa))

#beta='Lola' #print(type(beta))

son=39.2 print(type(son))


#3. O‘zgaruvchi uchun qiymat kiritilganda, uning turini #aniqlovchi dastur tuzing.

a=input('a=') print(type(a))


#31-dars mashqlari

#1.Quyidagi o‘zgaruvchilar turini aniqlang: #alfa = 579413; beta = 'Aqlbek'; d = True; #s = 0; resp = ’d’; b = 100; max = False;

#fc = ’True34’; t = 102.5; res = ’2500’; #a = ’-50’; b = 45.67

alfa=579413 #3print(type(alfa)) #x=input() #beta='Aqlbek' #print(type(beta)) #x=input() #d=True #print(type(d)) #x=input() #t=102.5

#print(type(t))
#2.Ikkita qayiq turg‘un suvda bir-biriga #tomon a km/soat va b km/soat tezlik bilan #suzmoqda. Ular orasidagi masofa S km bo‘lsa, #ular qancha vaqtda uchrashadi? a va b #foydalanuvchi tomonidan kiritiladi.
#v1=int(input('birinchi qayiqning tezligi=')) #v2=int(input('ikkinchi qayiqning tezligi=')) #S=int(input('Oralaridagi masofa=')) #v=v1+v2

#S=v*t. t=S/v. v=v1+v2 #t=S/v

#print('t=',t,' soat')
#3.Xonaning bo‘yi (x) va eni (y) metr #foydalanuvchi tomonidan kiritiladi. #Xonaning yuzasi (S) va perimetri

#(P)ni topish dasturini tuzing.

#a=int(input('a='))

#b=int(input('b='))

#1)

#S=a*b


#print('S=',S,'mert kadrat') #x=input()

#2) #P=2*(a+b)

#print('P=',P,'metr')
#6.Doiraning radiusi r ga teng. #Doiraning yuzi (s) va aylana uzunligi

# l ni topish dasturini tuzing. Doiraning #radiusi foydalanuvchi tomonidan kiritiladi #(PI=3.14).


#1)pi=3.14 #s=pi*r*r pi=3.14

r=int(input('r=')) s=pi*r*r

print('s=',s,'metr kvadrat')
#2) l=2*pi*r x=input() l=2*pi*r print('l=',l,'metr')
#1.Berilgan a va b sonlari yig‘indisi, ko‘paytmasini #toping. Yig‘indi va ko‘paytma oxirgi raqamlarining #ko‘paytmasini topish dasturini tuzing.

#33-dars masalalari

#Berilgan Ifoda Natija

# a = 8 d = a + b = 8 + 9 =17 S=7*2=14

# b = 9 c = a * b = 8 * 9 = 72 #a=8

#b=9


#d=a+b #print("d=",d) #c=a*b #print("c=",c) #x=d%10

#print(x) #y=c%10

#print(y) #S=x*y

#print("S=",S)


#2.Berilgan ikki xonali son xonalarining yig‘indisini #hisoblash dasturini tuzing.
#print("ikki xonali son kiriting") #x=int(input())

#a=x//10 #b=x%10

#S=a+b #print("S=",S)
#3.Quyidagi ifodani Python tilida yozing: #1)x + 2y + 52 * 4–58

x+2*y+(5**2)*4-58 #2)256+(2589–1549)*458+45614–4565/5 256+(2589-1549)*458+456**14-4565/5


#35-dars masalalari

#1.Hovuzning bo‘yi 6 metr, eni 4 metr va #chuqurligi 3 metr. Berilganlar asosida #quyidagi topshiriqlar uchun dastur tuzing: #a)Hovuz ichiga kafel qoplash uchun qancha #kvadrat metr kafel kerak bo‘ladi?

#b)Hovuzni to‘ldirish uchun qancha litr suv #kerak bo‘ladi (1 l = 1000 cm3)?
#a=6#metr #b=4#metr #c=3#metr #s=a*b+2*b*c+2*a*c

#print("Kafel qoplash uchun",s,"kvadrat metr maydon") #v=a*b*c

#print("v=",v*1000,"litr")
#2.Yuqoridagi masalada hovuz bo‘yi, eni va #chuqurligi kattaliklari foydalanuvchi #tomonidan kiritiladigan hol uchun #dastur tuzing.
#print("Hovuzning bo`yi a") #a=int(input()) #print("hovuzning eni b") #b=int(input())

#print("Hovuzning chuqurligi") #c=int(input()) #s=a*b+2*b*c+2*a*c

#print("Kafel bosiladigan yuza",s,"metr kvadrat") #v=a*b*c

#print("Hovuzning hajmi",v*1000,"litr")

#3.10 288 sekundni soat, minut va #sekundlarda ifodalang.

#t=10288 #sekund #tm=t/60#minut #ts=tm/60#soat

#print("t=",t,"sek=",tm,"min=",ts,"soat")

#4.Berilgan ikki xonali son xonalarining #ko‘paytmasini hisoblash dasturini tuzing.


#a=int(input('a=')) #b=a//10 #c=a%10

#kupaytma=b*c #print("kupaytma",kupaytma)

#5.Berilgan uch xonali son xonalarining #yig‘indisi va ko‘paytmasini hisoblash #dasturini tuzing.
#Berilgan Ifoda Natija
# 897 8+9+7 24

# 8*9*7 504


print("Uch xonali son kiriting") a=int(input())

print(a) br=a//100

print("birinchi raqam-",br) iir=a//10

ir=iir%10

print("ikkinchi raqam",ir) ur=a%10

print("uchinchi raqam",ur) s=br+ir+ur

p=br*ir*ur

print("Raqamlar yig`indisi-",s) print("Raqamlar ko``paytmasi-",p)

#6.Qisqartirilgan amallarni qo‘llagan holda, #quyidagi dastur natijasini chiqaring.
#Berilgan Ifoda Natija



#

a=8

a=int(input())

#

b=5

b=int(input())

#

c=9

c=int(input())

#




a-=b

#




a*=c

#




a+=(b*c+b)

#




print(a)

print('Butun a ni kiriting') a=int(input()) print('Butun b ni kiriting') b=int(input()) print('Butun c ni kiriting') c=int(input())

a-=b print(a) a*=c

print(a) a+=(b*c+b)

#7. Quyidagi ifodani Python tilida yozing: # y= 7

# x2+x+1+x2 #y=7/(x*x+x+1)+x*x


#37.1-topshiriq

#1. “GULTOJIXO‘ROZ” so‘zidan qism so‘zlar #ajratuvchi dastur tuzing. a='GULTOJIXO`ROZ'

b=a[:3]


print(b) c=a[3:7]

print(c) d=a[7:13]

print(d) input()
#37.2-topshiriq
#2.TUZAMAN, PYTHON, DASTUR, TILIDA, MEN.

#Ushbu so‘zlardan jumla tuzuvchi dastur tuzing. A='TUZAMAN'

B='PYTHON ' C='DASTUR ' D='TILIDA ' E='MEN ' P=E+B+D+C+A

print(P) input()

#37.3-topshiriq

#3.Foydalanuvchi tomonidan kiritilgan matn #uzunligini aniqlovchi dastur tuzing.


print('Matn kiriting') a=str(input())

print("siz kritgan matnda ",len(a),'ta belgi bor.') input()

#37.4-topshiriq

#“*” lar yordamida uchburchak yasang.

print(' * ')

print(' * * ')

print(' * * * ')

print('* * * *')


input()

#37.5-topshiriq

#“+”yordamida kvadrat yasang. print('+ '*4)

print('+ '*4)

print('+ '*4)

print('+ '*4) input()


#37.6-topshiriq

#Belgilar yordamida pingvin yasang. print(" ~ ")

print(" - - ")

print(" (o o) ") print(" / V \ ") print(" /(_)\ ") print(" ^^ ^^ ")


#38-dars 1-uy vazifasi

#1.Kutubxonaga ikkita kitob do‘konidan kitoblar keltirildi.

#Birinchi do‘kondan n dona kitob keltirildi. Ikkinchi do‘kondan esa #birinchi do‘konga qaraganda k dona ko‘p kitob keltirildi. #Kutubxonaga jami qancha kitob keltirildi? Masalani yechish #dasturini tuzing. n va k kattaliklar foydalanuvchi tomonidan kiritiladi.
print('Birinchi do`kondan keltirilgan kitoblar soni n ni kiriting/') n=int(input())

print('Ikinchi do`kondan keltirilgan ortiqcha kitoblar soni k ni liriting/') k=int(input())

J=n+n+k

print('Jami kitoblar soni ',J,'ta') input()


#38-dars 2-uy vazifasi

#2.Komilaga 854*89657*4587*425 amalini dasturga kiritib, #hisoblash topshirig‘i berildi. U qanday dastur tuzishi lozim?


s=854*89657*4587*425

print('s=',s)

#9-sinf IAT 41.1

#1. Tomoni a ga teng kvadrat ichiga doira chizilgan. #Bo‘yalgan soha yuzi s ni topish dasturini tuzing. from math import*

PI=3.14

print('kvadrat tomoni uzunligini kiriting') a=float(input())

skv=pow(a,2) sd=PI*pow((a/2),2) s=skv-sd

print(s) input()

#9-sinf IAT 41.2

#2.Foydalanuvchi tomonidan kiritilgan sondan avval va #keyin keluvchi sonni ekranga chiqaruvchi dastur tuzing. print('a butun son kiriting')

a=int(input()) b=a-1

c=a+1 print(b,':',c) input()

#9-sinf IAT 41.3

#3.n nafar o‘quvchi k dona olma terdi va olmalar ular #o‘rtasida teng taqsimlandi. Qoldiq olmalar savatchaga solindi. #a)Har bir o‘quvchi qanchadan olma olgan?

#b)Savatchaga qancha olma solingan?

#n va k kattaliklar foydalanuvchi tomonidan kiritiladigan #hol uchun dastur tuzing.

print('n ni kiriting') n=int(input()) print('k ni kiriting') k=int(input()) t=n//k

q=n%k print(t,q)

input()

#9-sinf IAT 41.4

#4.Foydalanuvchi tomonidan kiritilgan ikki xonalidan katta #natural sonning oxirgi ikki raqamini topish dasturini tuzing. print('99< a son kiriting')

a=int(input()) q=a%100

print(q) input()

#9-sinf IAT 41.5

#5.Avtobus bir kunda n kilometr yo‘l yuradi. m kilometr #masofani bosib o‘tishi uchun avtobus necha kun yurishi #kerak? n va m kattaliklar foydalanuvchi tomonidan kiritiladi. #Masalani yechish dasturini tuzing.

print('n ni kiriting') n=int(input()) print('m ni kiriting') m=int(input()) kun=m//n print(kun)

#6.Chumolining bosib o‘tgan yo‘li millimetrlarda berilgan. #Uni metr, santimetr va millimetrlarda ifodalang #(masalan, 45 786 = 45 metr 78 cm 6 mm).

input() m=45786

mm=m%10 sm1=m%1000 sm=sm1//10 me=m//1000

print(me,'metr',sm,'sm',mm,'mm') input()

#9-sinf IAT 41.7

#7.Kubning tomoni a ga teng. Kubning hajmini #topish dasturini tuzing.

print("kub qirrasi uzunligi a ni kiriting") a=float(input())

V=a**3 print(V) input()


#9-sinf IAT 41.8

#8.a, b, c, d sonlari berilgan. Ularning o‘rta arifmetigini #topish dasturini tuzing.

print(' to`rtta son kiriting') a=input().split() a1=float(a[0]) a2=float(a[1]) a3=float(a[2]) a4=float(a[3]) ar=float((a1+a2+a3+a4))/4

print(ar) input()

#9-sinf IAT 41.

#5-masalaga qarang


42-DARS

#1.Quyidagi mantiqiy ifodalar natijasini yozing: print((3 > 5) and (2 > 4))

input()

print((2 < 5) and (3 > 0)) input()

print((4 > 2) or (4 < 1)) input()

print((3 > 1) or (5 > 0)) input()


#2.Quyidagi mantiqiy ifodalar natijasini toping: #a)
a = 20

b = 28

print(a>17 and b==28) input()
#b)

a = 20

b = 28

c=True


print(a>17 and b>22 and c)

44-DARS


#1.Mantiqiy ifodalar qiymatini aniqlash uchun #dastur tuzing va natijasini oling:

a=8 b=a**3

print(a

b=a*3 print(a<=b/3) input()

a=8 b=a

c=(a+b==2*b) print(c) input()

a=8 b=a-4

print((a+3)>=(b-2))

input()

#3.Mantiqiy ifodalar natijasini toping: a = 20

c = False

d=a > 17 or c print(d) input()

a = 20

c = False



d=not a > 17 or not c print(d)

#2.Mantiqiy ifodalar qiymatini aniqlang: a=(1 > 3) or (4 < 0)


b=not (5 > 6) print(b) c=not (6 > 5) print(c)

d=(2 == 0) or (2 != 2)

print(d)

e=(2 == 0) and (2 > 0)

print(e)

f=(3 > 0) or (2 > 0)

print(f)
a = True b = True c = False

d=(not(a and c) and (a or b) or c) print(d)

a = 66

b = 22

c = 7

d=not((a > b) or (b < c)) print(d)



#4.Mantiqiy ifodalar qiymatini aniqlash uchun #dastur tuzing va natijasini oling: a=int(input("a="))

b=(a<=5 or a>=0 and a<3) print(b)

input() a=int(input("a="))

b=int(input("b="))

c=int(input("c="))

x=int(input("x="))

y=int(input("y="))

d=(x**2+y>0 and a==0.1 or (b>3.7 and c!=4))

print(d) input()

a=int(input("a="))

b=int(input("b="))

s=(a<1 or a>0 or not (x*x+x*x<=1)) print(s)

input()

d=not(not(not(a>b) or True) and False) print(d)


46-DARS

#1.Ikkita a va b son berilgan. Agar b son a sondan #kichik bo‘lsa, u holda b ni nol bilan almashtiruvchi, #aks holda b ni o‘zgarishsiz qoldiruvchi dastur tuzing. #46-dars 1-topshiriq

a=int(input('a='))

b=int(input('b=')) if a

b=0 print('b=',b) input()
#46-dars 2-topshiriq

#2.Berilgan a butun son noldan farqli b butun songa


#qoldiqsiz bo‘linishi yoki bo‘linmasligini aniqlovchi #dastur tuzing.

a=int(input('a='))

b=int(input('b=')) c=a%b

if c==0:


print(a, ' soni', b, ' soniga qoldiqsiz bo`linadi') else:

print(a, ' soni', b, ' soniga qoldiqsiz bo`linmaydi') input()


#46-dars 3-topshiriq

#3.Berilgan a butun son noldan farqli b butun songa #qoldiqsiz bo‘linsa, bu ikkala sonning yig‘indisini, #aks holda ko‘paytmasini topish dasturini tuzing. a=int(input('a='))

b=int(input('b=')) c=a%b

if c==0:


d=a+b else:

d=a*b print(d)

input()

#46-dars 4-topshiriq


#4.Uchta a, b va c son berilgan. Agar a2 – b2 = c2 #shart bajarilsa, ularning ko‘paytmasini, aks holda #yig‘indisini hisoblovchi dastur tuzing.
a=int(input('a='))

b=int(input('b='))

c=int(input('c=')) if a*a-b*b==c*c:

p=a*b*c print(p)

else:

s=a+b+c print(s)



input()

#46-dars 5-topshiriq

# 5.Butun son berilgan. Agar u musbat bo‘lsa, unga 1 #sonini qo‘shish, aks holda o‘zini chiqarish dasturini tuzing.
a=int(input('a=')) if a>0:

a=a+1 print('a=',a)

input
#46-dars 6-topshiriq
#6.Kiritilgan butun son musbat bo‘lsa, uning 10 ga ko‘paytmasini, #aks holda o‘zini chiqaruvchi dastur tuzing.

a=int(input('a=')) if a>0:

a=a*10 else:

a=a print('a=',a)


# 47-dars. TARMOQLANUVCHI ALGORITMLARNI DASTURLASH. #ELIF OPERATORI

#1. Ikki xonali sonning raqamlari toq #ekanligini aniqlovchi dastur tuzing.

#47-dars 1-misol a=int(input('bi=')) b=a//10

i=a%10


if b%2!=0 and i%2!=0: print('raqamlar toq',b,':',i)

else:


print(' raqamlar toq emas',b,':',i)

input()


#47-dars 2-misol

#2. Uch xonali sonda bir xil raqamlar #mavjudligini aniqlovchi dastur tuzing.


print('uch xonali son kriting') a=int(input('a='))

b=a%10 i=b%10 u=i%10

if b==i or i==u or b==u:

print('bir hil raqamlar mavjud') else:

print('bir hil raqamlar mavjud emas') input()
#47-dars 3-misol
#3.a va b sondan qaysi biri juft #ekanligini aniqlovchi dastur tuzing.
a=int(input('a='))

b=int(input('b='))


a1=a%10 a2=b%10

if a1%2==0:

print('a soni juft',a) if a2%2==0:

print('b soni juft',b) input()


#47-dars 4-misol

#4.3 ta butun son kiritildi. Qaysi biri juft #ekanligini aniqlovchi dastur tuzing.


a=int(input('a='))

b=int(input('b='))

c=int(input('c=')) a1=a%10 a2=b%10 a3=c%10

if a1%2==0:

print('a soni juft',a) if a2%2==0:

print('b soni juft',b) if a3%2==0:

print('c soni juft',c)
#48-dars. AMALIY MASHG‘ULOT

#1.Uchta a, b va c butun son berilgan. Ular orasidan #musbatlari sonini topish dasturini tuzing.


#48-dars 1-mashq

a=int(input('a='))

b=int(input('b='))

c=int(input('c=')) s=0

if a>0:

s+=1


if b>0:

s+=1


if c>0:

s+=1


print('musbat sonlar',s,'ta') input()

#48-dars 2-mashq

#2.Uchta a, b va c butun son berilgan. Ular orasidan #musbat va manfiylari sonini topish dasturini tuzing.

a=int(input('a='))

b=int(input('b='))

c=int(input('c=')) mus=0

man=0 if a>0:

mus+=1 if a==0:

man==man if a<0:

man+=1 if b>0:

mus+=1 if b==0:

man==man if b<0:

man+=1 if c>0:

mus+=1 if c==0:

man==man if c<0:

man+=1 print('mus=',mus,'man=',man)

input()

#48-dars 3-mashq


#3.Ikkita a va b son berilgan. Dastlab kattasini, keyin #esa kichigini chiqaruvchi dastur tuzing.
a=int(input('a='))

b=int(input('b=')) if a>b:

print(a,b) else:

print(b,a) input()

#48-dars 4-mashq
#4.Uchta a, b va c butun son berilgan. Ulardan faqat #musbatlari kvadratini hisoblab chiquvchi dastur tuzing.
a=int(input('a='))

b=int(input('b='))

c=int(input('c=')) if a<=0:

a=0 else:

a=a*a if b<=0:

b=0 else:

b=b*b if c<=0:

c=0 else:

c=c*c s=a+b+c print(a,b,c) input()
#48-dars 5-mashq

#5.Kvadrat tenglamani yechish dasturini tuzing. a=int(input('a='))

b=int(input('b='))

c=int(input('c='))

D=b*b-4*a*c

from math import* if D>=0:

x1=(-b-sqrt(D))/(2*a)

x2=(-b+sqrt(D))/(2*a)


print('x1=',x1,'x2=',x2) else:

print('yechimga ega emas') input()


#48-dars 6-mashq

#6.Hafta raqami 1–7 oraliqda kiritilganda, hafta kunini #ekranga chiqaruvchi dastur tuzing.


a=int(input('Xaftaning nechanch kuni')) if a==1:

print('Dushanba') if a==2:

print('Seshanba') if a==3:

print('Chorshanba') if a==4:

print('Payshanba') if a==5:

print('Juma') if a==6:

print('Shanba') if a==1:

print('Yakshanba')


if a<1 or a>7: print('Bunday kun yo`q')

input()


#48-dars 7-mashq

#7.a va b sonlar berilgan. Agar ular musbat va yig‘indisi #100 dan katta bo‘lsa, a sonining b songa nisbatini, ular #musbat va yig‘indisi 100 dan katta bo‘lmasa, a ning b ga #ko‘paytmasini hisoblash dasturini tuzing.


a=int(input('a='))

b=int(input('b=')) c=a+b

if a>0 and b>0 and c>100: s=a/b

if a>0 and b>0 and c<=100: s=a*b

print(s) input()
#48-dars 8-mashq

#8.Ikkita son berilgan. Agar birinchi son ikkinchisidan katta #bo‘lsa, 1 ni, agar ikkinchi son birinchisidan katta bo‘lsa,

#2 ni, agar ikkalasi teng bo‘lsa, 0 ni chiqaruvchi dastur tuzing.
a=int(input('a='))

b=int(input('b=')) if a>b:

print(a) if b>a:

print(b) if a==b:

print(0)

#49–50-darslar. TAKRORLANUVCHI ALGORITMLARNI DASTURLASH. #FOR OPERATORI


#49-dars 1-topshiriq

#1.a va b sonlar berilgan. a dan b gacha bо‘lgan barcha #sonlarni chiqaruvchi dastur tuzing. Bu yerda a <= b.


print('a<=b shartni bajaruvchi a va b sonlarini kiriting ') a=int(input('a='))

b=int(input('b=')) if a>b:

print('xato kiritdingiz') else:

for i in range(a,b+1): print(i, end=':')

input()
#49-dars 2-topshiriq

#2.a va b sonlar berilgan. Agar a < b bо‘lsa, a dan b gacha #bо‘lgan sonlarni о‘sish tartibida, aks holda kamayish #tartibida chiqaring.


a=int(input('a='))

b=int(input('b=')) if a

for i in range(b,a-1,-1):

print(i, end=':') if a>=b:

for i in range(a,b-1,-1):

print(i, end=':') input()


#49-dars 3-topshiriq

#3.1 dan 10 gacha bо‘lgan natural sonlar kvadratlarini #chiqaruvchi dastur tuzing.


for i in range(1,11): print(i,'ni kvadrati',i*i)

input()


#49-dars 4-topshiriq

#4.1 dan 10 gacha bо‘lgan natural sonlar yig‘indisini #chiqaruvchi dastur tuzing.


i=1;s=0

for i in range(11):

s=s+i print('s=',s)
#51-dars. AMALIY MASHG‘ULOT

#51-dars 2-mashq

#2.1 dan n gacha bо‘lgan natural sonlar kvadratlari yig‘indisini #aniqlovchi dastur yozing.
n=int(input('n=')) s=0

for i in range(1,n+1): k=i*i

s=s+k print(s) input()

#51-dars 3-mashq

#3.n>=2 shartni qanoatlantiruvchi n soni berilgan. Ushbu ifodani #hisoblovchi dastur tuzing. d=1*2+2*3+...+(n–1)*n

#print('n>=2 shartni bajaruvchi sonni kiriting') d=0

n=int(input('n='))

for n in range(2,n+1): k=(n-1)*n

d=d+k print(d) input()

#51-dars 4-mashq

#4.Bir nechta son berilgan. Ular orasida qancha 2 soni bor ekanligini #aniqlovchi dastur tuzing.
print('Nechta son kiritasiz?') a=int(input('a='))

s=0


for i in range(a): print('sonni kiriting') n=int(input('n='))

if n==2: s=s+1

print(s,'ta 2 raqami mavjud') input()

#51-dars 5-mashq

#5.S=11+13+15+…+49 yig‘indini hisoblash dasturini tuzing. s=0

for i in range(11,49,2): s=s+i

print('s=',s) input()

#51-dars 6-mashq. Va nihoyat juda sodda holda chidi


#6. n ta uchburchakni ekranga chiqaruvchi dastur tuzing. n –1 #dan 9 gacha bо‘lgan natural sonlarni qabul qiladi.

n=int(input('n='))

for i in range(1,n+1): print(' * ')

print(' * * ')

print(' * * * ')

print('* * * *')


#52 dars 1-mashq

#1.Butun son kiritilgan vaqtda sondan avval va keyin #keluvchi sonni chiqaruvchi dastur tuzing. Dastur #natijasi quyidagicha bo‘lishi lozim.


#Kiruvchi ma’lumot Chiquvchi ma’lumot # 254 254 dan avvalgi son bu – 253 # 254 dan keyingi son bu – 255
a=int(input('a=')) b=a-1

c=a+1


print(a," dan avvalgi son-",b) print(a," dan keyingi son-",c) input()
#52 dars 2-mashq

#2.Natural son berilgan. Shu son oxirgi raqamini #topish dasturini tuzing.


a=int(input('a=')) b=a%10

print("siz kiritgan ",a," sonining oxirgi raqami-",b)

input()
#52 dars 3-mashq

#3.Sutkaning n sekundi berilgan. Sutka boshlanganidan #beri qancha soat (h), minut (min) va sekund (s)

#o‘tganini aniqlash dasturini tuzing.

#masalan, n = 13257 = 3*3600 + 40*60 + 57; h = 3 va min = 40.


print('Izoh: 86400 sekund bir sutka, a sekundni kiriting') a=int(input('a='))

s=a%60 #sekund ok=a//60 #oraliq kattalik min=ok%60 #min h=ok//60

print(a, 'sekund-',h,'soat',min,'min',s,'sekund') input()

#52 dars 4-mashq

#4.Mahsulotning narxi s so‘m. Ushbu mahsulotdan n ta sotib #olish uchun qancha so‘m sarflash kerak?
print('Mahsulot narxi s ni kiriting') s=int(input('s='))

print('Xarid miqdotini kiriting-') n=int(input('n='))

M=s*n

print('kerakli pul-',M,' so`m') input()



#52 dars 5-mashq

#5.Musbat butun son berilgan. Ushbu sonning o‘nliklar xonasidagi #raqamini aniqlash dasturini tuzing.


print('Musbat sonni kiriting') a=int(input('a='))

if a>0:


b=a//10 c=b%10

print('Sonning o`nli raqami-',c) input()

#52 dars 6-mashq
#6.Ismingizni kiritganda quyidagi xabarni chiqaruvchi dasturni #tuzing. Dastur tuzishda print() operatorining end() usulidan #foydalaning.
#Kiruvchi ma’lumot Chiquvchi ma’lumot #Lola Xush kelibsiz, Lola!

print('Ismingizni kiriting-') a=input('a=')

print('Hush kelibsiz, ',a,'!')
#53-dars 1-misol
#1.0 dan 20 gacha bo‘lgan juft sonlarni ekranga #chiqaruvchi dastur tuzing.

n=0


while n<=20: print(n) n+=2

input()


#53-dars 2-misol
#2. n va k butun manfiy bo‘lmagan sonlar berilgan. #n va k qatnashgan ushbu ifodani hisoblang.

from math import* n=int(input('n=')) k=int(input("n>k="))

a=factorial(n) b=factorial(k) c1=n-k c=factorial(c1) F=a/(b*c) print('F=',F) input()

#53-dars 3-misol

#3.a va b natural sonlar berilgan. a dan b gacha #bо‘lgan sonlar orasidan faqat juftlarini chiqaruvchi #dastur tuzing. Bu yerda a <= b.
a=int(input('a=')) b=int(input("a

for a in range(a,b+1): if a%2==0:

print(a) input()

#53-dars 4-misol

#4.n natural soni berilgan. Kvadrati n dan kichik

#bo‘lgan barcha natural sonlarni chiqaruvchi dastur tuzing


from math import* n=int(input('n=')) x=int(sqrt(n))

i=1


while i<=x:

print(i) i+=1


#54-dars 1-mashq

#1. S = 0,5 + 1,5 + 2,5 +…+ 98,5 + 99,5

#ifodani hisoblash dasturini tuzing.

s=0 i=0.5

while i<=100: s=s+i

i+=1


print(s) input()

#54-dars 2-mashq


#2. n natural sonining barcha bo‘luvchilarini #chiqaruvchi dastur tuzing.
n=int(input('n=')) i=0

while i<=n+1:

i+=1

b=n/i a=n//i if a==b:



print(a) input()
#54-dars 3-misol 1-usul
#3.Kiritilgan n soni qancha raqamdan iborat #ekanligini aniqlovchi dastur tuzing (ko‘rsatma: #n = n%10 ifoda n = 0 bo‘lguncha bajariladi).
n=int(input('n=')) a=len(str(n))

print(n,'soni ',a,' ta raqamdan iborat' ) input()


#54-dars 4-mashq

#4.Kiritilgan n soni raqamlari yig‘indisini #hisoblovchi dastur tuzing.

a=input('a=') n=len(a) a=int(a)

s=0


for i in range(1,n+1): b=a//(10**(i-1))%10 s+=b
print(s) input()

#54-dars 5-mashq

#5.Kiritilgan n soni juft raqamlari sonini #hisoblovchi dastur tuzing.
a = input('Sonni kiriting: ') n = len(a)

a=int(a) j = 0

for i in range(1,n+1): b=a//(10**(i-1))%10 if b%2==0:

j+=1


print(j,'ta juft raqam bor')

input()


#54-dars 6-mashq

#6.n natural soni berilgan. 1 dan n gacha bo‘lgan #natural sonlar ichida oxirgi raqami 3 gа karrali #sonlarni chiqaruvchi dastur tuzing.

a = int(input('Sonni kiriting: '))

for i in range(1,a): b=i%10

if b%3==0 and b!=0: print(i)

#1. Qo‘shish, ayirish, ko‘paytirish va bo‘lish #amallaridan iborat sodda kalkulyator dasturini tuzing.


#55-dars 1-masala a=int(input('a ni kiriting, a=')) b=int(input('b ni kiriting, b='))

print('amalni kiriting va enterni bosing') amal=input('+ - * /')

if amal=='+': c=a+b

elif amal=='-': c=a-b

elif amal=='*': c=a*b

elif amal=='/': c=a/b

else:

c=(' AMAL XATO!')



print('natija c=',c)

#2.Foydalanuvchi tomonidan kiritilgan sonlar #yig‘indisini hisoblash dasturini tuzing. Agar

#manfiy son kiritilsa, sikl o‘z ishini to‘xtatishi lozim.
while True: a=int(input('a='))

b=int(input('b=')) if a>=0 and b>=0:

s=a+b print('s=',s)

else:


break
# 56-dars 1-misol

#n va k butun musbat sonlar berilgan. n va k #qatnashgan ushbu ifodani hisoblang. #n!/k!(n-k)! Funksiyadan foydalaning.

def factorial(n): if n==0:

return 1 else:

natija=n*factorial(n-1) return natija

n=int(input('n= '))

k=int(input('k= ')) m=n-k N=factorial(n) K=factorial(k) M=factorial(m) S=N/(K*M)

print('natija=',S)


#56-dars 2-masala

#n natural son berilgan. Kvadrati n dan kichik #bo‘lgan barcha natural sonlarni chiqaruvchi #dastur tuzing.
from math import* i=1

n=int(input('n= '))

m=int((sqrt(n))) while i<=m:

print(i) i+=1


#56-dars 3-masala
#3.Bir birlik uzunlik ‘-’ ga teng. Berilgan n #uzunlikdagi ‘-’ belgidan iborat chiziq chizuvchi #dastur tuzing. Protseduradan foydalaning.
print('nechta _ belgisi qo`yilsin? a=') a=int(input())

print('_'*a)


#58-dars 1-masala
#1.‘*’ belgisidan tomoni n ga teng kvadrat chizuvchi #dastur tuzing. Protseduradan foydalaning.

#Kiruvchi ma’lumot Chiquvchi ma’lumot

# n n x n ta (‘*’) dan iborat kvadrat

# ***


# 3 ***

# ***


n=int(input('n=')) j=1

for j in range(1,n+1): def kvadrat():

i=1

for i in range(1,n+1): print('*',end=' ')



return print(kvadrat())

#58-dars 2-masala

#2.Berilgan n sonining bo‘luvchilarini bitta qatorda #probel orqali ajratib chiqaruvchi dastur tuzing. #Protseduradan foydalaning.

#Kiruvchi ma’lumot Chiquvchi ma’lumot # 6 1236

n=int(input('n=')) for i in range(1,n+1):

a=n%i if a==0:

print(i, end=' ')

#58-dars 3-masala

#3.Berilgan n sonini rim raqamlarida ifodalovchi dastur #tuzing. Protseduradan foydalaning.
#Kiruvchi ma’lumot Chiquvchi ma’lumot
# 125 CXXV

a=int(input('0

if i==2:

r='II'


if i==3:

r='III'


if i==4:

r='IV'


if i==5:

r='V'


if i==6:

r='VI'


if i==7:

r='VII'


if i==8:

r='VIII'


if i==9:

r='IX'


ir=0

if b==1: ir='X'

if b==2: ir='XX'

if b==3: ir='XXX'

if b==4: ir='XC'

if b==5: ir='L'

if b==6: ir='LX'

if b==7: ir='LXX'

if b==8:

ir='LXXX'

if b==9: ir='XC'

ur=0


if u==1: ur='C'

if u==2: ur='CC'

if u==3: ir='CCC'

if u==4: ur='CD'

if u==5: ur='D'

if u==6: ur='DC'

if u==7: ur='DCC'

if u==8: ur='DCCC'

if u==9: ur='CM'

print(ur+ir+r)


rim raqami kiritilsa(qo`shimcha)

t = input("*(I,V,X da iiborat) Rim raqamida son kiriting=")

for j in t:

if j != "I" and j != "V" and j != "X": exit()

a = t

t = list(t) s = 0

for i in range(0, len(t)): n = i - 1

m = i + 1

if n < 0:

n += 1

if m >= len(t): m -= 1

if t[i] == "I" and t[m] != "V" and t[m] != "X":

s += 1

elif t[i] == "I" and t[m] == "X": s += 9

elif t[i] == "I" and t[m] == "V": s += 4

elif t[i] == "V" and t[n] != "I": s += 5

elif t[i] == "X" and t[n] != "I": s += 10
print("Son ", a, " o`nlik sanoq sistemasida ", s, " bo`ladi.", sep="") #58-dars 4-masala

#4.Berilgan n soni xonalarining yig‘indisini hisoblash #dasturini tuzing. Protseduradan foydalaning. #Kiruvchi ma’lumot Chiquvchi ma’lumot


# 125 8

n=input('n=')

from math import* a=len(n)

a=int(a) n=int(n)

s=0 i=1

while i<=a:

b=n%pow(10,i)//pow(10,(i-1))

i+=1


s=s+b print(s)
#58-dars 5-masala

#5.Sport musobaqasida sportchilarning chiqishlari hakamlar #tomonidan ballik tizimda baholandi. Yakuniy ballni olish #uchun eng yuqori va eng past ball chiqarib tashlandi va #qolgan uchta ballning o‘rtacha arifmetik qiymati hisoblandi.

#5 nafar hakam tomonidan berilgan eng yuqori va eng past ballni #hamda sportchi olgan ballni chiqaradigan dastur tuzing. #Funksiyadan foydalaning.
#Kiruvchi ma’lumot Chiquvchi ma’lumot

# 12345 15

# 3.00

a1=int(input('a1=')) a2=int(input('a2='))



a3=int(input('a3=')) a4=int(input('a4=')) a5=int(input('a5=')) ma=max(a1,a2,a3,a4,a5) mi=min(a1,a2,a3,a4,a5) sr=(a1+a2+a3+a4+a5-ma-mi)/3 print('eng katta ball-',ma,end=';') print('eng kichik ball-',mi,end=';') print('o`rtacha ball-',sr,end=';')
#58-dars 6-masala
#6.Berilgan n soni xonalari raqamlarining sonini #chiqaruvchi dastur tuzing.

#Kiruvchi ma’lumot Chiquvchi ma’lumot # 647521 6

n=input('n=') m=len(n)

print(' siz kiritgan',n,'soni',m,'ta raqamdan iborat ')


#59-dars 1-masala

#1. n natural soni berilgan. #S=1*5+2*6+3*7+…+n*(n+4)

#ifodani hisoblash dasturini #protsedura yordamida tuzing.
n=int(input('n=')) s=0

for i in range(1,n+1): s=s+i*(i+4)

i+=1

print(s)
#59-dars 2-masala



# 2.a va b natural sonlari berilgan. # a va b sonlaridan kattasini topish # funksiyasini tuzing. Funksiyadan

# foydalanib, a, b va c sonlari ichidan # kattasini topish dasturini tuzing.

def max(a, b): if a > b:

return a else:

return b

def max3(a, b, c):

return max(max(a, b), c) a = int(input('a='))

b = int(input('b='))

c = int(input('c='))

print(max3(a,b,c))


#61-dars 1-masala #1. Berilgan to‘rtta

#sonning eng kichigini #topuvchi dastur tuzing. #Buning uchun
from math import*

a = int(input('a='))

b = int(input('b='))

c = int(input('c='))

d = int(input('d='))

print(min(a,b,c,d))


64

#61-dars 2-masala



#2.Berilgan a (haqiqiy) sonining

#k (butun) darajasini topuvchi dastur #tuzing. Buning uchun daraja (a, k) #funksiyasini yarating.


from math import* def daraja(a,k):

b=pow(a,k) return b

a=int(input('a='))

k=int(input('k=')) print(daraja(a,k))


#61-dars 3-masala

#3.Inglizcha harf va raqamlardan iborat #satr berilgan. Ushbu satr qancha raqamdan #iboratligini hisoblovchi dastur tuzing.
print('Satrni kiriting:') a=input('a=') n=len(a)

s=0


for i in range(n):
65

if a[i].isdigit(): s=s+1

print(s)
#61-dars 4-masala

#4.Berilgan sonni akslantiruvchi dastur #tuzing. Masalan, 123 dan 321 ni hosil #qiling. Funksiyadan foydalaning.


a=input('a=') print(a[::-1])

#61-dars 5-masala

#0 bilan tugaydigan sonlar ketma-ketligi #berilgan. Uning raqamlari yig‘indisini #sikl ishlatmagan holda hisoblash #dasturini tuzing
a=input('a=') n=len(a) a=int(a)

66

s=0



from math import* if a%10==0:

for i in range(1,n+1): r=a//pow(10,i-1)%10

#6.Tonna, kilogramm va grammlarda #berilgan birlikni grammga aylan- #tirish funksiyasini yozing.


67

print("Masssani kiriting") t=int(input('tonna=')) k=int(input('kg='))



g=int(input('g=')) m=1000000*t+1000*k+g print('m=',m,'g')

# 62-dars 1-masala

#11.0 va 1 ning oralig‘idan #10 ta tasodifiy sonni chiqa- #rish dasturini tuzing.

from random import* for i in range(10):

a=randint(0,10) i+=1

print(i,'- son',a) input()


#2.0 va 1 ning oralig‘idan 100 #ta tasodifiy sonni chiqarish #dasturini tuzing.

68

from random import* for i in range(100):



a=randint(1,100)/100 i+=1

print(i,'- son',a) input()

#3.10 va 10000 ning oralig‘idan #5 ta tasodifiy sonni chiqarish #dasturini tuzing.
from random import* for i in range(5):

a=randint(10,10000) i+=1

print(i,'- son',a) input()
#4.20 va 50 ning oralig‘idan 2 #qadam bilan 7 ta tasodifiy sonni #chiqarish dasturini tuzing.
from random import* for i in range(7):

a=randrange(20,50,2) i+=1

69

print(i,'- son',a)



# 64-dars masalalari yechimlari #1. Berilgan burchak yoyining #uzunligini hisoblovchi dastur #tuzing. Yoyning burchagi (gradusda) #hamda radiusi foydalanuvchi #tomonidan kiritiladi.
r=int(input('r=')) alfa=int(input('alfa=')) pi=3.14

l=pi*r*alfa/180 print('l=',l)


#2.y = x * cos x funksiyasi

#qiymatini hisoblovchi dastur tuzing. #x foydalanuvchi tomonidan kiritiladi.


from math import* x=float(input('x=')) y=x*cos(x) print('y=',y)
70

#3.Kvadrat tenglamaning ildizlarini #hisoblash dasturini tuzing. a, b, c #foydalanuvchi tomonidan kiritiladi.


from math import* a=int(input('a='))

b=int(input('b='))

c=int(input('c=')) d=b*b-4*a*c

if d==0: print('x1=x2=',b/2*a)

if d>0:

print('x1=',(-b-pow(d,2)/(2*a)))

print('x2=',(-b+pow(d,2)/(2*a))) if d<0:

print('tenglama yechmga ega emas',end='.')

#4.Berilgan haqiqiy sonning kasr qismini

#1 dan 4 gacha bo‘lgan aniqlikda yaxlitlang. #a=0.26598


##Natija:

#1-aniqlikda: 0.3 2-aniqlikda: 0.27

#3-aniqlikda: 0.266 4-aniqlikda: 0.2660

71

for i in range (1,5): n=round(a,i)



print(i,'- aniqlikda',(n)) i+=1
#5.Doira sektorining yuzasini hisoblash #dasturini tuzing. Doiraning radiusi hamda #sektorning burchagi (gradusda) foydalanuvchi #tomonidan kiritiladi.
r=int(input('r=')) alfa=int(input('alfa=')) pi=3.14

l=pi*r*r*alfa/360 print('l=',l)


#65-dars masalalari

#1.Rangi yashil, o‘lchami

#100×100 bo‘lgan “Mening birinchi #ilovam” nomli GUI oynasini #yaratuvchi dastur kodini yozing. #Oynada “Salom O‘zbekiston” xabarini #chiqaruvchi tugmachasini joylashtiring. from tkinter import *

window=Tk()


72

window.title("Mening birinchi ilovam") window.geometry("100x100") window.configure(background="green")

my_label=Label(window, width=15, height=5, bg="green", text="") my_label.grid(row=0, column=0)

def change_text(): my_label.config(text="Salom O`zbekiston!")

my_button=Button(window,text="Meni bosing!", width=10, command=change_text)

my_button.grid(row=1, column=0) window.mainloop()

#2.Rangi pushti, o‘lchami 250×150 bo‘lgan “Mevalar” nomli GUI oynasini #yaratuvchi dastur kodini yozing. Oynada berilgan 4 ta mevadan birini #tanlash imkonini beruvchi vijetni joylashtiring.
from tkinter import * window = Tk() window.title('mevalar') window.geometry('250x150')

window.configure(background='magenta') my_label=Label(window, width=5, height=5, bg='magenta', text='') my_label.grid(row=0, column=0)


73

jinsi=StringVar()

radio1=Radiobutton(window, text='olma',variable=jinsi, value='olma') radio1.grid(row=0, column=0, sticky=W) radio1=Radiobutton(window, text='anor',variable=jinsi, value='anor') radio1.grid(row=0, column=1, sticky=W)

radio1=Radiobutton(window, text='shaftoli',variable=jinsi, value='shaftoli') radio1.grid(row=0, column=2, sticky=W)

radio1=Radiobutton(window, text='gilos',variable=jinsi, value='gilos') radio1.grid(row=0, column=3, sticky=W)
Radiobutton() radio1.select() window.mainloop()

74

Izohlar uchun















































































Download 245.11 Kb.

Do'stlaringiz bilan baham:




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