N butun son berilganu ning darajasi ekanligini aniqlang


) Berilgan N natural sonni rim sanoq sistemasiga


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

19) Berilgan N natural sonni rim sanoq sistemasiga
o’tkazadigan dasturni f-ya yordamida tuzing
n=int(input())
def int_to_roman(n):
roman_numerals = {
1000: 'M',
900: 'CM',
500: 'D',
400: 'CD',
100: 'C',
90: 'XC',
50: 'L',
40: 'XL',
10: 'X',
9: 'IX',
5: 'V',
4: 'IV',
1: 'I'
}
roman_numeral = ''
for value, numeral in roman_numerals.items():
while n >= value:
roman_numeral += numeral
n -= value
return roman_numeral; print(int_to_roman(n))


27)”Output” nomli fayldagi matndagi necha xil sonlar mavjudligini
aniqlovchi dastur tuzing.
from random import*
l=[]
file=open("output","w")
for i in range(20):
file.write(str(randint(1,15))+" ")
file.close()
file=open("output","r")
a=file.read()
a1=a.split()
for j in a1:
l.append(int(j))
l1=set(l)
print(len(l1))


20) Ismlar kortajda 2 va undan ortiq ismi borlarni aniqlansin va necha
marotaba takrorlangani chiqarilsin?
n=tuple(input().split())
n1=list(n)
n2=set(n)
n3=list(n2)
for i in range(len(n3)):
x=n1.count(n3[i])
if x>=2:
print(n3[i],x,'marta')


28) “Output” nomli fayldagi matndagi simmetrik matnlarni “input”
faylga yozuvchi dastur tuzin?
l=list(map(str,input().split()))
file=open("output","w")
for i in l:
file.write(i+" ")
file=open("output","r")
a=file.read()
a1=a.split()
file1=open("input","w")
for i in a1:
if i==i[::-1]:
file1.write(i+" ")
file1.close()
file1=open("input","r")
b=file1.read()


24) Sonli turdagi ketma-ketlikni satriy turga o’tkazuvchi dastur tuzing
class satr():
def init(self,a):
self.a=str(a)
son=satr(5)
print(son.a)



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