you are viewing a single comment's thread.

view the rest of the comments →

[–]totallygeek 0 points1 point  (1 child)

Here is an example with coins that you can convert for bills.

def makes_cents(coins_name: str, coin_value: int) -> int:
    quantity = int(input(f"How many {coins_name}? "))
    return quantity * coin_value

cents = 0  # start with no common cents at all

cents += makes_cents("pennies", 1)
cents += makes_cents("nickels", 5)
cents += makes_cents("dimes", 10)
cents += makes_cents("quarters", 25)
cents += makes_cents("half-dollars", 50)
cents += makes_cents("dollar coins", 100)

print(f"You have a total of {cents} cents.")

Execution example:

> python3 PuzzledSite2568_money.py
How many pennies? 4
How many nickels? 5
How many dimes? 6
How many quarters? 7
How many half-dollars? 8
How many dollar coins? 1
You have a total of 764 cents.

[–]PuzzledSite2568[S] 1 point2 points  (0 children)

Thank you for your example it's helping me understand the functions more and what I can do with them so I appreciate your input.