Header Ads

Python - WAP to determine the Average of N Number's in Python - 10

This is a Python Code to Print the Average Number of any given Number.

Source Code:
#!/usr/bin/python3

while True:

    # Get Total Number of Elements.
    A = int(input("Enter Total Number of Elements : "))

    total = 0

    # Getting the Values of Elements.
    for idx in range(1, A+1):
        B = int(input("Enter Value of % d : " % idx ))
        total += B
        # Calculating the Average
        avg = total / A

    # Printing the Average Number.
    print ("The Average is : %.3f" % avg )

    # Continue Block.
    if (input(">> To Continue ['y'] : ") == 'y' ):
        continue
    else:
        break

Program Output:

....

No comments