A cashier distributes change using the maximum number of five-dollar bills, followed by one-dollar bills. Write a single statement that assigns num_ones with the number of distributed one-dollar bills given amount_to_change. Hint: Use %. Sample output with input: 19

Respuesta :

Answer:

amount_to_change = int(input("Enter amount to change: "))

num_fives = amount_to_change // 5

num_ones = amount_to_change % 5

print("There are " + str(num_fives) + " five dollars and " + str(num_ones) + " one dollars in the change")

Explanation:

Ask the user to enter the amount_to_change

Calculate the number of five dollars, use floor division

Calculate the number of one dollars, use modulo operator

Print the number of five dollars and number of one dollars

Otras preguntas