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))
Do'stlaringiz bilan baham: |