Monday, 21 February 2022

Write a program that finds the average of a series of numbers entered by the user.

 Write a program that finds the average of a series of numbers entered by the user. As in the previous problem, the program will first ask the user how many numbers there are. Note: The average should always be a float, even if the user inputs are all ints.

CODE :

# sumnn.py 

def main() :

    n = int (input ("How many numbers are to be summed: ") ) 

    sum=0

    for i in range(n) :

        a = int (input ("Please enter number  : ") ) 

        sum=sum+a

    print ("Average of a series of numbers :",sum/n) 

main()

SCREENSHOT





No comments:

Post a Comment