I am trying to make a program that gives you the average, total, and biggest number entered. I am stuck at the biggest number part. My numbers are not in a list, so I don't know how to find the biggest one.
num=0
total=0
average=0
count=0
while True:
num=input("enter a number:")
num=int(num)
if num==-999:
break
total=total + num
count=count+1
biggest = max(total)
average=total/count
#print the results
print("the total is:", total)
print("the biggest number is:", biggest)
print("the average is:", average)
I would like it to print the biggest number at the end.
Thanks
Let me share you a solution for your problem. (Take a look at the if clause after the check of the number being "-999"). Feel free to ask if you have any questions! Hope it helps you
num=0
total=0
average=0
count=0
biggest=0
while True:
num=input("enter a number:")
num=int(num)
if num==-999:
break
if num > biggest:
biggest = num
total=total + num
count=count+1
average=total/count
#print the results
print("the total is:", total)
print("the biggest number is:", biggest)
print("the average is:", average)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments