N butun son berilganu ning darajasi ekanligini aniqlang


Download 134.94 Kb.
bet1/10
Sana22.06.2023
Hajmi134.94 Kb.
#1647477
  1   2   3   4   5   6   7   8   9   10
Bog'liq
dasturlash shpargalka


1)N butun son berilganu 2 ning darajasi ekanligini aniqlang
n=int(input())
def son(n):
if n<=0:
return False
while n>1:
if n%2!=0:
return False
n=n//2
return True
if son(n):
print(f”{n} 2 ning darajasi”)
else: print(f”{n} 2 ning darajasi emas”)

2) Dasturchilar kuni tilning 255-kunida nishonlanadi(1-yanvar nolinchi kun


hisoblanadi). Ma’lum bir yilda dasturchilar kuni qaysi sanaga
togri kelishini toping
y=int(input())
if y%400==0:
print(‘12/09/’+str(y))
elif y%4==0 and y%100!=0:
print(‘12/09/’+str(y))
else:
print(‘13/09/’+str(y))

3)Berilgan sonda nechta tur raqam mavjud,f-ya yormadiga aniqlang


def son(n):
a=set(str(n))
print(len(a))
n=int(input())
son(n)


9) “Output” nomli faylga N ta [a,b] oraliqdagi ixtiyoriy sonlarni
yozuvchi dasturni funksiya yordamida tuzing.
from import random
a,b=map(int,input().split()) file=open(“input”,”w”)
for i in range(10):
file.write(str(randint(a,b+1))+” “)
file.close(); file=open(“input”,”r”);
c=file.read(); print( c )


10) Sonli kortejda necha xil son borligini topuvchi dastur tuzing
sonlar = input(“sonlar ketma-ketligini kiriting”)
y = set(sonlar.split())
b=len(y)
count = len(noyob_sonlar)
print(count)


5)Berilgan matndagi sonlarni “output” nomli faylga yozuvchi
Dastur tuzing
output=open(‘C:/output.txt’,’w+’)
s=input()
for i in range(len(s)):
if s[i] in k:
output.write(s[i]+’ ‘)
output.close()

12) (x: x*x) ko‘rinishida (a dan b gacha) sonlarni
o‘z ichiga olgan lug‘at yarating
a = int(input("a ni kiriting: "))
b = int(input("b ni kiriting: "))
lugat = {}
for x in range(a, b+1):
lugat[x] = x*x
print(lugat)



Download 134.94 Kb.

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




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