From 0360f215e1797829c8774dac25d5b88a9d2b4bc9 Mon Sep 17 00:00:00 2001 From: Saksham Sharma <89659787+SakshamSharma07@users.noreply.github.com> Date: Thu, 13 Oct 2022 23:01:19 +0530 Subject: [PATCH] Max-Min value in array This program gives the maximum and minimum value of the array --- Python/array/maxMin.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Python/array/maxMin.py diff --git a/Python/array/maxMin.py b/Python/array/maxMin.py new file mode 100644 index 0000000..069b6d3 --- /dev/null +++ b/Python/array/maxMin.py @@ -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 \ No newline at end of file