Python平均分数

Python平均分数,python,Python,基本上,除非输入负数,否则我需要进行输入,然后打印分数和其他统计数据以及所有数据。问题现在已经解决了 nums=[] total= 0 count= 0 while x >= 0: x = int(input("Enter a number (enter -1 to terminate): ")) if x <= 100: total = total + x count+=1 nums.append(x)

基本上,除非输入负数,否则我需要进行输入,然后打印分数和其他统计数据以及所有数据。问题现在已经解决了

nums=[]
total= 0
count= 0

while x >= 0:
    x = int(input("Enter a number (enter -1 to terminate): "))

    if x <= 100:
        total = total + x
        count+=1
        nums.append(x)

    if x>100:
        print("Invalid entry.")
    x = int(input("Enter a number (enter -1 to terminate): "))
print(nums)
print("Number of scores: ", len(nums))
nums=[]
总数=0
计数=0
当x>=0时:
x=int(输入(“输入一个数字(输入-1终止):”)
如果x 100:
打印(“无效条目”)
x=int(输入(“输入一个数字(输入-1终止):”)
打印(nums)
打印(“分数:,len(nums))

看起来第二个输入应该在while循环的末尾

while x >= 0:

    if x <= 100:
        total = total + x
        count+=1
        nums.append(x)

    if x>100:
        print("Invalid entry.")

    x = int(input("Enter a number (enter -1 to terminate): "))
当x>=0时:
如果x 100:
打印(“无效条目”)
x=int(输入(“输入一个数字(输入-1终止):”)

这给了第一个值一个被处理的机会,并且意味着最后的
-1
将不会被追加

是的,修复了它。谢谢