Skip to content

Commit

Permalink
Max-Min value in array
Browse files Browse the repository at this point in the history
This program gives the maximum and minimum value of the array
  • Loading branch information
SakshamSharma07 authored Oct 13, 2022
1 parent 4f036cf commit 0360f21
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Python/array/maxMin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Function to find minimum and maximum position in list
def maxminposition(A, n):
# inbuilt function to find the position of minimum
minposition = A.index(min(A))
# inbuilt function to find the position of maximum
maxposition = A.index(max(A))
print ("The maximum is at position::", maxposition + 1)
print ("The minimum is at position::", minposition + 1)
# Driver code
A=list()
n=int(input("Enter the size of the List ::"))
print("Enter the Element ::")
for i in range(int(n)):
k=int(input(""))
A.append(k)
maxminposition(A,n)

# Output
# Enter the size of the List ::4
# Enter the Element::
# 12
# 34
# 1
# 66
# The maximum is at position:: 4
# The minimum is at position:: 3

0 comments on commit 0360f21

Please sign in to comment.