Question

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:

Answers

  1. They are writing the values of the coins and the sum using their understanding of the computational language Python.

    What is Python?

    Python is a general-purpose, high-level programming language that is interpreted. Code readability is a priority in its design philosophy, which uses substantial indentation. Garbage collection and dynamic typing are features of Python.

    According to the given information:

    Writing code in python      
    quarters = int(input())
    dimes = int(input())
    nickels = int(input())
    pennies = int(input())
    cents = (quarters*25 + dimes*10 + nickels*5 + pennies)
    #convert cents to dollars
    # 1 dollar = 100 cents
    # n cents = n/100 dollars
    dollars = cents / 100.00
    #Print the amount in dollars up to two decimal places
    print(“Amount: $”+”{:.2f}”.format(dollars))
    To know more about python visit:
    #SPJ4
    I understand that the question you are looking for is:
    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 input is non-negative

    Reply

Leave a Comment