-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathques7.py
More file actions
30 lines (26 loc) · 774 Bytes
/
ques7.py
File metadata and controls
30 lines (26 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'''
Program: Write a program to sort all the elements in ascending order using bubble sort
Author: Bikramadittya Bagchi
Date: 04-03-2021
'''
def bubbleSort():
arr1 = []
size = int(input("Enter the size of array: "))
print("Taking input for ARRAY\n")
for i in range(size):
inp = int(input("Enter element for array: "))
arr1.append(inp)
# Sorting the entered array
i, j = 0, 0
for i in range(size):
for j in range(i+1, size):
if arr1[i]>arr1[j]:
temp=arr1[i]
arr1[i]=arr1[j]
arr1[j]=temp
print ("The sorted array is : " + str(arr1))
def main():
print("Implementing Bubble sort with list")
bubbleSort()
if __name__ == "__main__":
main()