8.16-masala. Berilgan N ta so‘zlardan eng uzunini aniqlang.
matn=str(input("Matn kiriting:"));
s=matn.split(' ');
maks=len(s[0]);
for i in range(len(s)):
if maksk=s[i];
print("Matnda eng uzun so'z:",k);
|
|
8.17-masala. Berilgan natural sonning xona birliklarini ajratib yozing.
matn=str(input("Natural sonni so'z bilan kiriting:"));
s1=len(matn);
for i in range(s1):
sn=matn[i:i+1];
print(sn,'..',end='');
|
|
8.18-masala. O‘ndan kichik bo‘lgan so‘zlarni ularga mos natural sonda chop eting.
matn=str(input("O'ndan kichik natural son kiriting:"));
n=len(matn);
if matn[0:n]=='bir':
t=1;
elif matn[0:n]=='ikki':
t=2;
elif matn[0:n]=='uch':
t=3;
elif matn[0:n]=="to'rt":
t=4;
elif matn[0:n]=="besh":
t=5;
elif matn[0:n]=="olti":
t=6;
elif matn[0:n]=="yetti":
t=7;
elif matn[0:n]=="sakkiz":
t=8;
elif matn[0:n]=="to'qqiz":
t=9;
else:
print("Bu bir xonali son emas yoki natural son emas");
print("Bu bir xonali son",t,'ga teng');
|
|
8.19-masala. Tiyinlarda berilgan pulni so‘m bilan ifodalang. Bunda tiyinlar ikki xonali sonlar bilan ifodalanadi.
m=str(input("Matn kiriting:"));
n=len(m);
for i in range(1,n):
m1=m[:i];
if m1=="o'n":
un=10;
elif m1=="yigirma":
un=20;
elif m1=="o'ttiz":
un=30;
elif m1=="qirq":
un=40;
elif m1=="ellik":
un=50;
elif m1=="oltmish":
un=60;
elif m1=="yetmish":
un=70;
elif m1=="sakson":
un=80;
elif m1=="to'qson":
un=90;
m2=m[i:];
if m2=='bir':
bir=1;
if m2=='ikki':
bir=2;
if m2=='uch':
bir=3;
if m2=="to'rt":
bir=4;
if m2=='besh':
bir=5;
if m2=='olti':
bir=6;
if m2=='yetti':
bir=7;
if m2=='sakkiz':
bir=8;
if m2=="to'qqiz":
bir=9;
natija=un/100+bir/100;
print(natija,'tiyin');
|
|
8.20-masala. Tushirib qoldirilgan harf o‘rniga H harfni yozishni o‘rgatuvchi dastur tuzing.
matn=str(input("Matn kiriting:"));
b=str(input('Harf kiriting:'));
t=matn.replace(b,"");
print(t);
|
|
Do'stlaringiz bilan baham: |