如何找到 python 中输入数字的平均值、最小值、最大值和范围?

How to go about finding the average, min, max and the range of the numbers of the input in python?

a = int(input('How many numbers do you want today? '))
for i in range(0,a):
    num=int(input('enter a number'))
    print(num)

now i want the average, min, max and the range of the numbers entered, what do you do next?

按space输入所有数字。 Python3 map 不再是 returns 列表,因此我们需要将其包装在列表调用中。

s = input()
numbers = list(map(int, s.split()))
avg = sum(numbers)/len(numbers)
min_val = min(numbers)
max_val = max(numbers)

[输出图像] https://i.stack.imgur.com/QVvM4.png

假设您没有向我们提供使用什么或不使用什么的任何条件。以下是您可以尝试的东西

number_input = input("Enter the number")
l=[]
for i in range(0,int(number_input)):
    l.append(i)
#print(l) #for the values storing I use list here
print("The maximum is:"+str(max(l)))
print("The minimum is:"+str(min(l)))
print("The average is:"+str(sum(l)/len(l)))

The output would look like:

Enter the number 10

The maximum is:9 The minimum is:0 The average is:4.5