In [67]:
import math
from __future__ import division
cost=float(raw_input("Please enter the price of the product: "))
amount=float(raw_input("Please enter amount given: "))
one_penny=1
dime=5
quater=25
cents=0
quatt=0
kill=0
result = amount - cost
def change(calc):
global cents
if calc == 0:
print "not change needed"
else:
if not float(calc).is_integer():
cents,dollars= math.modf(calc)
print "Change will be $%s dollars and $%.2f cents" %(dollars, cents)
cents=round(cents,2)
cents=cents * 100
def qua(calc):
global quatt
if calc > quater:
rest_quater=int(calc/quater)
print "Please provide %s quaters" %rest_quater
test= rest_quater * quater
quatt= calc -test
else:
pass
def tens(calc):
global dimm
if calc < quater:
rest_tens=int(calc/dime)
print "Please provide %s dime" %rest_tens
test= rest_tens * dime
dimm= calc -test
else:
pass
def kilo(calc):
global kill
if calc < dime :
rest_kilo=int(calc/one_penny)
print "Please provide %s penny" %rest_kilo
test= rest_kilo * one_penny
kill= calc -test
else:
pass
change(result)
qua_coins=qua(cents)
dim_coins=tens(quatt)
kilo_coins=kilo(dimm)
In [50]:
change(result)