PYTHON PROGRAM TO PRINT TOTAL AND AVERAGE OF THREE NUMBERS
Write a program that asks the user to enter three numbers (use three separate input statements). Create variables called total and average that hold the sum and average of the three numbers and print out the values of total and average.
CODE:
a=float(input("Enter a-value:"))
b=float(input("Enter b-value:"))
c=float(input("Enter c-value:"))
total=a+b+c
average=total/3
print("Total is:",total)
print("Average is:",average)
EXPLANATION:
In first three lines of code, the program asks the user to enter three values (a,b,c).
In the next two lines, the programs computes the total and average of the three entered numbers and stores the value in total and average variables respectively.
Using print() function it prints the total and average of the three numbers.
OUTPUT:
Comments
Post a Comment