Tech Study

Write a Python program to calculate the sum and average of n integer numbers. Input 0 to finish

Introduction

Write a Python program to calculate the sum and average of n integer numbers. Input 0 to finish.

I have used python 3.7 compiler for debugging purpose.

print("Input some integers to calculate their sum and average. Input 0 to exit.")
 
count = 0
sum = 0.0
number = 1
 
while number != 0:
    number = int(input(""))
    sum = sum + number
    count += 1
 
if count == 0:
    print("Input some numbers")
else:
    print("Average and Sum of the above numbers are: ", sum / count)

Result

Write a Python program to calculate the sum and average of n integer numbers. Input 0 to finish
Write a Python program to calculate the sum and average of n integer numbers. Input 0 to finish

TaggedWrite a Python program to calculate the sum and average of n integer numbers. Input 0 to finish

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more