پاسخ ها (2)
2
phoenix
کد پایتون
inputvalues=input("please input your numbers: ").split()
numbers=list(map(int, inputvalues))
result = 0
for t in numbers:
result +=t
result /= len(numbers)
print("The average is: ", result)
1
zero
کد ورودی اعداد با فاصله
inputList=list(map(int, input("please input your number list, split with space: ").split()))
def cal_average(num):
sum_num = 0
for t in num:
sum_num = sum_num + t
avg = sum_num / len(num)
return avg
print("The average is: ", cal_average(inputList))
مثال:
input: 1 2 3
output: 2.0
پاسخ به سوال