Test 1
text = "this is not a reversed text"
def reverse(x):
newText=""
cnt=len(x)-1
while cnt>=0:
newText+=x[cnt]
cnt=-1
return newText
print("reversed string is: "+reverse(text))
Test 2
no_list = [22,68,90,78,90,88]
def average(x):
aver=0
cnt=0
while cntaver+=x[cnt]
cnt+=1
aver/=len(x)
return aver
print(average(no_list))
Test 3
no_list = [1,2,3,4]
def maximum(no_list):
max=0
cnt=0
while cnt<=len(no_list):
if maxmax=no_list[cnt]
cnt+=1
return max
print(maximum(no_list))
Test 4
no_list = [22,22,2,1,11,11,2,2,3,3,3,4,5,5,5,55,55,66]
def unique_list(l):
l.sort()
newList=[]
current=1[0]
newList.append(current)
cnt=0
while cntif currentcurrent=l[cnt]
newList.append(current)
cnt+=1
return newList
print(unique_list(no_list))
Do'stlaringiz bilan baham: |