Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sabareeshwaran/leaders in a python #3527

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
18 changes: 18 additions & 0 deletions leaders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Creating a bubble sort function
def bubble_sort(list1):
# Outer loop for traverse the entire list
for i in range(0,len(list1)-1):
for j in range(len(list1)-1):
if(list1[j]>list1[j+1]):
temp = list1[j]
list1[j] = list1[j+1]
list1[j+1] = temp
return list1

list1 = []
num=int(input("enter the number of elements in the array : "))
for i in range(num):
arr =int(input("enter the element : "))
list1.append(arr)

print("The leader of the array",list1[-1])
21 changes: 21 additions & 0 deletions leaders/python/leaders in a array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Creating a bubble sort function
def bubble_sort(list1):
# Outer loop for traverse the entire list
for i in range(0,len(list1)-1):
for j in range(len(list1)-1):
if(list1[j]>list1[j+1]):
temp = list1[j]
list1[j] = list1[j+1]
list1[j+1] = temp
return list1

list1 = []
num=int(input("enter the number of elements in the array : "))
for i in range(num):
try:
arr =int(input("enter the element : "))
except ValueError:
print('Enter a valid number')


print("The leader of the array",list1[-1])
19 changes: 19 additions & 0 deletions sort/projectsort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Creating a bubble sort function
def bubble_sort(list1):
# Outer loop for traverse the entire list
for i in range(0,len(list1)-1):
for j in range(len(list1)-1):
if(list1[j]>list1[j+1]):
temp = list1[j]
list1[j] = list1[j+1]
list1[j+1] = temp
return list1

list1 = []
num=int(input("enter the number of elements in the array : "))
for i in range(0,num):
user_input = int(input("Enter a number: "))
list1.append(user_input)


print("The leader of the array",list1[-1])