Selection Sort

# Selection Sort

def selectionSort(array, n):
for i in range(n - 1):
for j in range(i + 1, n):
if array[j] < array[i]:
array[j], array[i] = array[i], array[j]
print("Sorted Array Of Percentage Of Students =", array)


size = int(input("Enter The Number Of Students\n"))
arr = []
for i in range(size):
userinput = int(input(f"Enter The Percentege Of Student {i + 1}\n"))
arr.append(userinput)
print("\nUnsorted Array Of Percentage Of Students =", arr)
selectionSort(arr, size)


# Output

# Enter The Number Of Students
# 10

# Enter The Percentege Of Student 1
# 82
# Enter The Percentege Of Student 2
# 92
# Enter The Percentege Of Student 3
# 89
# Enter The Percentege Of Student 4
# 75
# Enter The Percentege Of Student 5
# 74
# Enter The Percentege Of Student 6
# 65
# Enter The Percentege Of Student 7
# 68
# Enter The Percentege Of Student 8
# 85
# Enter The Percentege Of Student 9
# 88
# Enter The Percentege Of Student 10
# 84

# Unsorted Array Of Percentage Of Students = [82, 92, 89, 75, 74, 65, 68, 85, 88, 84]
# Sorted Array Of Percentage Of Students = [65, 68, 74, 75, 82, 84, 85, 88, 89, 92]

Comments

Popular posts from this blog

Python Program To Store Marks

Currency.txt

Python Comprehensions