Qurilishni boshqarish fakultetiti axborot texnologiylari kafedrasi
Download 1.01 Mb.
|
Axtamov jahongir (2)
TOSHKENT ARXITEKTURA-QURILISH UNVERSITETI QURILISHNI BOSHQARISH FAKULTETITI AXBOROT TEXNOLOGIYLARI KAFEDRASI Qurilishda axborot texnologiyalari Fanidan 1-MUSTAQIL ISH Bajardi: Axtamov J Guruh: 1-22 Tekshirdi: Ko’paysinov SH. TOSHKENT 2022 1. [23, 14, 56, 12, 19, 9, 15, 25, 31, 42, 43] berilgan to’plam ichidagi juft va toq sonlarni o’rta arifmetigini aniqlovchi dastur tuzing? Dasturda list, for, if-else operatorlaridan foydalaning? a=[23,14,56,12,19,9,15,25,31,42,43] b=[] #Bo'sh list c=[] #Bo'sh list e=[] for x in a: if x%2==0: b.append(x) e=sum(b)/len(b) else: c.append(x) f=sum(c)/len(c) print(b) print(f"juf sonlar o'rta arifmetigi {e} ga teng") print(c) print(f"toq sonlar o'rta arifmetigi {f} ga teng") 2. [1, 0, 0, 1, 1, 0, 1, 1] ikkilik sanoq sistemadan o’nlik sanoq sistemasiga otishni dasturini tuzing? Dasturda list, for opetatorlaridan foydalaning? print("a1*(2**n)+a2*(2**(n-1))+...am*(2**0)") x=[1,0,0,1,1,0,1,1] print(f'Ikkilik sanoq sistemasi={x}') s=len(x)-1 #Oxirgi element indeksi c=0 for y in x: c=c+y*(2**s) s=s-1 print(f"O'nlik sanoq sistemaga o'tkazilgani {c} ga teng") 4. elements = [23, 14, 56, 12, 19, 9, 15, 25, 31, 42, 43] quyidagi to’plamdagi juft va toq sonlarning yigindisini hisoblovchi dastur tuzing? Dasturda list, for, if-else operatorlaridan foydalaning? a=[23,14,56,12,19,9,15,25,31,42,43] b=[] #Bo'sh list c=[] #Bo'sh list e=[] for x in a: if x%2==0: b.append(x) e=sum(b) else: c.append(x) f=sum(c) print(b) print(f"juf sonlar {e} ga teng") print(c) print(f"toq sonlar {f} ga teng") 5. Foydalanuvchidan biror butun son kiritishni so'rang. Foydalanuvchi kiritgan sonni 2 da 10 gacha bo'lgan sonlardan qay biriga qoldiqsiz bo'linishini konsolga chiqaring. a=int(input('Natural son kiriting=')) b=[] for x in range(2,10): if a%x==0: b.append(x) print(f"Bu son 2 dan 10gacha bo'lgan sonlar oralig'iga kiruvchi quyidagi sonlarga bo'linadi: {b}") 6. a dan b gacha bo’lgan sonlarning (a va b butun son) o’rta geometrigini toppish dasturini tuzing? from math import factorial a=int(input('a=')) b=int(input('b=')) d=list(range(a,b)) print(d) f=(factorial(b-1)/factorial(a-1))**(1/len(d)) print(f) 7. a va b butun son (a,n >0) S = 1 + a + a2 + a3 + … + an quydagi ifodaning hisoblash dasturini tuzing? print("1+a+a**2+a**3+...a**n") a=int(input('a=')) n=int(input('n=')) s=0 for x in range(0,n+1): s=s+a**x print(f"Yuqoridagi formulaga binoan javob {s} ga teng") 8. a dan b gacha bo’lgan sonlar oralig’idagi (a va b butun son) toq sonlarning kublarini yig’indisini hisoblash dasturini tuzing. a=int(input("a=")) b=int(input("b=")) d=[] for x in range(a,b+1): if x%2==1: d.append (x**3) p=sum(d) print(d) print(f"a va b sonlar orasidagi toq sonlari kublari yig'indisi {p} ga teng") 9. a dan b gacha bo’lgan sonlar oralig’idagi (a va b butun son) juft sonlarning kvadratlarini yig’indisini hisoblash dasturini tuzing. a=int(input("a=")) b=int(input("b=")) d=[] for x in range(a,b+1): if x%2==0: d.append (x**2) p=sum(d) print(d) print(f"a va b sonlar orasidagi juft sonlari kublari yig'indisi {p} ga teng") 11. a dan b gacha oraliqdagi sonlardan 3 ga ham 7 ga ham bo’linadiganlarini soni nechtaligini aniqlab beruvchi dastur tuzing? a=int(input("a=")) b=int(input("b=")) d=[] for x in range(a,b+1): if x%3==0 and x%7==0: d.append (x) p rint(f"bu oraliqda 3 ga ham 7 ga ham bo'linadigan sonlar quyidagilar:{d}") Download 1.01 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling