-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This program gives the maximum and minimum value of the array
- Loading branch information
1 parent
4f036cf
commit 0360f21
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |