K,vbmta3w зх. Оли сэпомвтлигини мустахжамлвш йилл леб эълон силим
Download 189.55 Kb.
|
1 2
Bog'liq9-IHT Python dasturlari
/^BALYQCHHO GURUHI/^
#61 -dars 5-masala #0 bilan tugaydigan soni... #61 -dars 5-masala a = int[input['O bilan tugaydigan son kiritingXn'}} if a 96 1 0 = = 0: b = list{str{a)) c = ItstfrriapfinLb]) printCaJ' = ,.sum(c)Jsep="} else: printt'Oxiri □ bilan tugamaydi'} #61-dars 6-masala #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
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
# 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
#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
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 #100x100 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.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 250x150 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
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
75
80 Download 189.55 Kb. Do'stlaringiz bilan baham: |
1 2
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling