0% found this document useful (0 votes)
15 views

Code2pdf 6715cc8f9b210

Uploaded by

kulkarnirugved52
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Code2pdf 6715cc8f9b210

Uploaded by

kulkarnirugved52
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#Rugved kulkarni SE_B-03

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}%")

print('Menu \n1.Selection sort \n2.Buble sort \n3.Exit')

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")

You might also like