#Write a program that reads a sequence of non-zero integers. First zero #value will terminate the input. The program finds and prints the number #of inputs, their sum and average. count=0 sum=0 #we have to read first input BEFORE the loop num=int(input("enter non zero, first zero stops the input ")) while(num!=0): count=count+1 sum=sum+num num=int(input("enter non zero, first zero stops the input ")) if(count>0): print("there are",count,"inputs") print("their sum is",sum) print("their average is",sum/count) else: print("empty input") #Tracing program for the following input: 3 -2 7 8 0 #count=0 sum=0 num=3 #loop starts #loop condition: num!=0, num is 3 now, 3!=0 is True,loop will be executed #loop will be executed #loop body: count=count+1=0+1=1, sum=sum+num=0+3=3, next input will be read, #num=-2 #loop condition: num!=0, num is -2, -2!=0 is True, loop will be executed #loop body: count=count+1=1+1=2, sum=3+(-2)=1, next input, num=7 #loop condition: num!=0, num is 7, 7!=0 is True, loop will be executed #loop body: count=count+1=2+1=3, sum=1+7=8, next num=8 #loop condition: num!=0, num is 8, 8!=0 is True, loop will be executed #loop body: count=count+1=3+1=4, sum=8+8=16, num=0 #loop condition: num!=0, num is 0, 0!=0 is False and loop will be terminated #After loop is done, count=4, sum=16 #count>0, True and if statement will be executed #final output: #there are 4 inputs #their sum is 16 #their average is 4.0