Code2pdf 6715cc8f9b210
Code2pdf 6715cc8f9b210
def selection_sort(arr):
for i in range (len(arr)):
min = i
for j in range(i+1,len(arr)):
if arr[min] > arr[j]:
min = j
arr[i],arr[min] = arr[min],arr[i]
return arr
def buble_sort(arr):
a = len(arr)
for i in range(a-1):
swapped = False
for j in range(a-i-1):
if arr[j] > arr[j+1]:
arr[j],arr[j+1]=arr[j+1],arr[j]
swapped = True
if not swapped:
break;
return arr
def Top_5(arr):
print('\nBelow are the top 5 scores:')
for i in range(1,6):
print(arr[-i])
li=[]
data=int(input("Enter the number of students: "))
for i in range(data):
per=float(input("Enter the percentage of student: "))
li.append(f"{per}%")
while True:
choice=int(input("\nEnter your choice: "))
if choice == 1:
result=selection_sort(li)
print(result)
elif choice == 2:
result=buble_sort(li)
print(result)
Top_5(li)
elif choice == 3:
break;
else:
print("enter a valid choice")