In python 3.17 LAB: Convert to dollars
Given four values representing counts of quarters, dimes, nickels and pennies, output the total amount as dollars and cents
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print(f'Amount: ${dollars:.2f}'
Ex: If the input is
4
3
2
1
where 4 is the number of quarters, 3 is the number of dimes, 2 is the number of nickels, and 1 is the number of pennies, the output is:
Amount: $1.41
For simplicity, assume inputis non-negative


Sagot :

To convert the inputs to dollars and cents, we make use of a combination of multiplication and addition.

The program written in Python where comments are used to explain each line is as follows:

#This gets input for the number of quarters

quarters = int(input("Quarters: "))

#This gets input for the number of dimes

dimes = int(input("Dimes: "))

#This gets input for the number of nickels

nickels= int(input("Nickels: "))

#This gets input for the number of pennies

pennies= int(input("Pennies: "))

#This converts the amount to dollars and cents

dollars = quarters * 0.25 + dimes * 0.10 + nickels * 0.05 + pennies * 0.01

#This prints the amount to 2 decimal places

print("Amount ${:.2f}".format(dollars))

Read more about Python programs at:

https://brainly.com/question/22841107