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

Popular posts from this blog

PYTHON PROGRAM THAT USES FOR LOOP TO PRINT THE NUMBERS 8,11,14,17,20,.........,83,86,89

PYTHON PROGRAM THAT ASKS THE USER TO ENTER TWO STRINGS OF SAME LENGTH AND WILL ALTERNATE THE CHARACTERS OF THE TWO STRINGS.FOR EXAMPLE: abcde and ABCDE THEN THE PROGRAM WILL PRINT AaBbCcDdEe

PYTHON PROGRAM THAT ASKS USER FOR LARGE INTEGERS AND INSERTS COMMAS INTO IT ACCORDING TO THE STANDARD AMERICAN CONVENTION FOR COMMAS IN LARGE NUMBERS