Program B 14 Selection Bubble
Program B 14 Selection Bubble
def Selection_Sort(marks):
for i in range(len(marks)):
#<--------------------------------------------------------------------------------------->
def Bubble_Sort(marks):
n = len(marks)
# Traverse through all array elements
for i in range(n - 1):
# Last i elements are already in place
for j in range(0, n - i - 1):
#<--------------------------------------------------------------------------------------->
def top_five_marks(marks):
print("Top Five Marks are : ")
if(len(marks)<6):
print(*marks[::-1], sep="\n")
else:
print(*marks[:len(marks)-6:-1], sep="\n")
#<---------------------------------------------------------------------------------------->
# Main
print("Jai Jadhav - [AIDS SE(B) - 22663]")
marks=[]
n = int(input("Enter number of students whose marks are to be displayed : "))
print("Enter marks for",n,"students (Press ENTER after every students marks): ")
for i in range(0, n):
ele = float(input())
marks.append(ele) # adding the element
print("The marks of",n,"students are : ")
print(marks)
flag=1;
while flag==1:
print("\n---------------MENU---------------")
print("1. Selection Sort of the marks")
print("2. Bubble Sort of the marks")
print("3. Exit")
ch=int(input("\n\nEnter your choice (from 1 to 3) : "))
if ch==1:
Selection_Sort(marks)
a=input("\nDo you want to display top marks from the list (yes/no) : ")
if a=='yes':
top_five_marks(marks)
else:
print("\nThanks for using this program!")
flag=0
elif ch==2:
Bubble_Sort(marks)
a = input("\nDo you want to display top five marks from the list (yes/no) : ")
if a == 'yes':
top_five_marks(marks)
else:
print("\nThanks for using this program!")
flag = 0
elif ch==3:
print("\nThanks for using this program!!")
flag=0
else:
print("\nEnter a valid choice!!")
print("\nThanks for using this program!!")
flag=0