making change counter, cant divide coins
<p>I have to design a program that when an amount of an item is entered,  asks the user for the amount paid,and then provides change in 20's 10's 5's 1s quarters, dimes, nickels, and pennies. I've spent hours trying to find the flaws in my code but I can't get it right. If someone could help me out that would be greatly appreciated!</p>

<p>I realize that my code is not very polished, but I just started and haven't learned too many techniques so far.
I have it all working until it hits dimes, then things go bad.</p>

<p>Here is my code at this point:</p>

<pre><code>#assign variables#
import math
cost=float(input("Enter the price of the item: $"))
paid=float(input("Enter the amount paid: $"))
#calculations#
difference=round(paid,2)-round(cost,2)
change= round(difference,2)
#twentys#
remain20=float(change%20)
twent=float(change-remain20)
twent1=abs(float(twent)//20)
twent2=float(twent1*20)
sub1=float(change-float(twent2))
print(sub1,"sub1")
#tens

remain10=change%10
ten=sub1-remain10
ten1=ten//10
ten2=ten1*10
sub2=sub1-ten2
print(sub2,"sub2")
#fives

remain5=float(abs(change%5))
five=abs(float(sub2)-float(abs(remain5)))
five1=float(round(abs(five)//5))
five2=float(round(five*5))
sub3=abs(float(sub2)-abs(float(five2)))
print(sub3,"sub3")
#ones
remain1=change%1
one=abs(round(sub3)-abs(remain1))
one1=abs(round(one//1))
one2=abs(round(one*1))
sub4=abs(float(sub3))-abs(float(one2))
print(sub4,"sub4")
#quarters
remainq=change%(0.25)
remainq1=round(remainq,2)
q=abs(sub4)-(remainq1)
q1=abs(q//float(0.25))
q2=abs(q*0.25)
sub5=abs(float(sub4))-(float(q2))
print(sub5,"sub5")
#dimes

remaind=change%(0.10)
remaind1=round(remaind,2)
d=abs(round(sub5,2)-remaind1)
d1=abs(d//float(0.10))
d2=abs(d1*0.10)
sub6=abs(float(sub5))-abs(float(d2))
print(sub6,"sub6")
#nickles

remainn=change%(0.05)
remainn1=round(remainn,2)
n=abs(round(sub6,2)-abs(remainn1))
n1=abs(d//float(0.05))
n2=abs(d1*0.05)
sub7=float(abs(sub6)-float(n2))
print(sub7,"sub7")
#pennies

remainp=change%(0.01)
remainp1=round(remainp,2)
p=abs(round(sub7,2)-abs(remainp1))
p1=abs(d//float(0.01))
p2=abs(d1*0.01)
#outputs
print(round(twent1),str("Twenty dollar bills"))
print(round(ten1),str("Ten dollar bills"))
print(round(five1),str("Five dollar bills"))
print(round(one1),str("One dollar bills"))
print(round(q1),str("Quarters"))
print(int(d1),str("dimes"))
print(int(n1),str("nickles"))
print(int(p1),str("Pennies"))
</code></pre>

<pre><code>import math

def to_pennies(amt):
  return int(math.floor(amt * 100))

def make_change(amt):
  pennies = to_pennies(amt)
  twenties = pennies % 2000
  pennies -= twenties * 2000
  fives = pennies % 500
  pennies -= fives * 500
  ...  # Fill in the rest
  nickels = pennies % 5
  pennies -= nickels * 5
  return dict(
    twenties=twenties,
    fives=fives,
    ... # fill in the rest
    nickels=nickels,
    pennies=pennies)
</code></pre>

python