Here is a possible implementation based on your code and the information available.
Basically, you create all your variables on top of the file, then loop until 5 numbers are entered (in this example) and do the necessary operations to calculate total, average, max and min values.
The minimum value is trickier, there is a workaround in the code below, you could also add the counter == 0
check in your if/elif
block for minimum with a little help from the or
operator.
total = 0
average = 0
maximum = 0
minimum = 0
counter = 0
while counter < 5:
input_number = int(input("Enter number: "))
total += input_number
if counter == 0:
minimum = input_number
if input_number > maximum:
maximum = input_number
elif input_number < minimum:
minimum = input_number
counter += 1
average = total / 5
print(total, average, maximum, minimum)
2
solved How to write a code to print the maximum of entered values?