WAP to calculate maximum and minimum element of a given list of numbers
Answers
Answered by
2
Required Answer:-
Question:
- Write a program to calculate maximum and minimum element of a given list of numbers.
Solution:
Here is the program. This is written in Python.
n=int(input("How many elements??? "))
l=[]
print("Enter them...")
for i in range(n):
l.append(int(input("Enter: ")))
print("Largest Element: ",max(l))
print("Smallest Element: ",min(l))
Explanation:
- The max() and min() function of Python is used to find out the maximum and minimum of a given list of numbers. Using this functions, the question is solved.
Refer to the attachment for output ☑.
Attachments:
Answered by
1
Program
numbers = [int(number) for number in input("Enter the numbers - ").split( )]
print(f" Max - {max(numbers)}\n Min - {min(numbers)}")
Algorithm
- Accepting the numbers.
- Finding and displaying the minimum and maximum elements.
Attachments:
Similar questions
Social Sciences,
2 months ago
Math,
2 months ago
Math,
4 months ago
Social Sciences,
4 months ago
Hindi,
11 months ago
Math,
11 months ago