top of page

Python Programming Help

Public·2 members

Python Program to calculate the total value of that change

Create a program, change.py, that has a function that takes 4 arguments that

correspond to the number of quarters, dimes, nickels, and pennies, respectively.

Calculate the total value of that change, and print "The total value of your change is $x"

where x is equal to the total value.


Hints:

A penny is worth 1 cent.

A nickel is worth 5 cents.

A dime is worth 10 cents.

A quarter is worth 25 cents



change.py



#defining function

def calculateToalValue(quarters, dimes, nickels, pennies):
    totalValue = 25 * quarters + 10 * dimes + 5 * nickels + 1 * pennies

    print("The total value of your change is $%.2f "%(totalValue/100))
    


#calling method
calculateToalValue(50, 25, 20, 10)


Output:


The total value of your change is $16.10


1369 Views
bottom of page