Giving change in quarters, dimes, and nickels, using Python -
i don't understand assignment:
write python program prompts user enter cost of item, , prompts user enter amount paid in cents. print change number of quarters, dimes, , nickels return (assume prices multiple of 5 cents).
here's code:
i = int(input('how did item cost')) p = int(input('how did pay')) e = p-i q = e/25 q = e%25 d = q/10 d = q%10`` n = d/5 n = d%5 print (' q = ',q,'\n d = ',d,'\n n = ',n)
this solution using division.
import math change = 50 quarterdif = change / 25 change -= math.floor(quarterdif) * 25 dimedif = change / 10 change -= math.floor(dimedif) * 10 nickeldif = change / 5 change -= math.floor(nickeldif) * 5 print(str(quarterdif) + str(dimedif) + str(nickeldif))
Comments
Post a Comment