write a program that prints the minimum and the maximum of five numbers entered by the user
Answers
Answered by
6
def _min(nums):
_min = nums[0]
for n in nums:
if _min > n:
_min = n
return _min
def _max(nums):
_max = nums[0]
for n in nums:
if _max < n:
_max = n
return _max
nums = [int(n) for n in input("enter 5 nums: ").split()]
print(f"min: {_min(nums)}\nmax: {_max(nums)}")
Answered by
2
Answer:
Solutionusingpython3
def _min(nums):
_min = nums[0]
for n in nums:
if _min > n:
_min = n
return _min
def _max(nums):
_max = nums[0]
for n in nums:
if _max < n:
_max = n
return _max
nums = [int(n) for n in input("enter 5 nums: ").split()]
print(f"min: {_min(nums)}\nmax: {_max(nums)}")
Similar questions