Respuesta :
Answer:
The program is as follows:
numlist = []
num = input("'stop' to end: ")
while not (num == "stop"):
numlist.append(int(num))
num = input("'stop' to end: ")
if len(numlist) == 0:
print("You didn't enter any numbers")
else:
print("The maximum is "+str(max(numlist))+" and The minimum is "+str(min(numlist)))
Explanation:
This declares an empty list
numlist = []
This prompts the user for input
num = input("'stop' to end: ")
This loop is repeated until the user enters 'stop'
while not (num == "stop"):
This appends the input to the list
numlist .append(int(num))
This prompts the user for input
num = input("'stop' to end: ")
If the length of the list is 0, then the user entered no input
if len(numlist) == 0:
print("You didn't enter any numbers")
If otherwise, this prints the min and the max
else:
print("The maximum is "+str(max(numlist))+" and The minimum is "+str(min(numlist)))
The program that accepts an arbitrary number of integer inputs from the user and prints out the minimum and maximum of the numbers entered is as follows:
numbers = []
x = input("Enter an integer and stop to end: ")
while not(x == "stop"):
numbers.append(int(x))
x = input("Enter an integer and stop to end: ")
if len(numbers) == 0:
print("You didn't enter any numbers ")
else:
print(f"The maximum number is {max(numbers)} and the minimum number is {min(numbers)}")
Code explanation:
The code is written in python
- The first line of code, we declared a variable named numbers and it is an empty list for storing our integers.
- The variable x is stores the user input
- while the user's input is not lowercase "stop", the user's input is appended to numbers.
- Then the program ask for the users input as long as it is an integers input
- if the length of the list is 0, then we print a statement to ask the user to enter a number.
- Else we print the maximum and minimum number of the user's input.
learn more on python code here: https://brainly.com/question/19175881

