Dasturga Muqaddima 1-bosqich



Download 5,68 Mb.
bet31/31
Sana01.07.2022
Hajmi5,68 Mb.
#722506
1   ...   23   24   25   26   27   28   29   30   31
Bog'liq
metodichka FS 2 labaratoriya tayyor

23-qism


Topshiriq



Kodi:
import random
import words


def silly_string(nouns, verbs, templates):
# Choose a random template.
template = random.choice(templates)


# We'll append strings into this list for output.
output = []


# Keep track of where in the template string we are.
index = 0


while index < len(template):
if template[index:index+8] == '{{noun}}':
# Add a random noun to the output.
output.append(random.choice(nouns))
index += 8
elif template[index:index+8] == '{{verb}}':
# Add a random verb to the output.
output.append(random.choice(verbs))
index += 8
else:
# Copy a character to the output.
output.append(template[index])
index += 1


# Join the output into a single string.
output = ''.join(output)


return output


if __name__ == '__main__':
print(silly_string(words.nouns, words.verbs,
words.templates))


2-Laboratoriya



Kod:
text = "this is not a reversed text"


def reverse(x):
temp=''
l=len(x)
for i in range(l):
temp+=x[l-i-1]
return temp


print("the reversed text is: "+reverse(text))

Kod:
no_list = [22,68,90,78,90,88]


def average(x):
av=0
for a in x:
av+=a
av=av/len(x)
return av



print(average(no_list))


Kod:
no_list = [1,2,3,4]


def maximum(x):
mx=0
for a in x:
if mx
mx=a
return a


print(maximum(no_list))


Kod:
no_list = [22,22,2,1,11,11,2,2,3,3,3,4,5,5,5,55,55,66]


def unique_list(l):
unil=[]
for a in no_list:
if a not in unil:
unil.append(a)
return unil


print(unique_list(no_list))
Download 5,68 Mb.

Do'stlaringiz bilan baham:
1   ...   23   24   25   26   27   28   29   30   31




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish