# Change for a dollar game # Global Constants PENNY_VALUE = 1 NICKEL_VALUE = 5 DIME_VALUE = 10 QUARTER_VALUE = 25 DOLLAR_VALUE = 100 def main(): penny = int(input()) nickel = int(input()) dime = int(input()) quarter = int(input()) CHANGE_FOR_DOLLAR(penny, nickel, dime, quarter) if CHANGE_FOR_DOLLAR(penny, nickel, dime, quarter) == DOLLAR_VALUE: print 'your exact change is a dollar' elif CHANGE_FOR_DOLLAR(penny, nickel, dime, quarter) > DOLLAR_VALUE: print 'the amount was more than a dollar' elif CHANGE_FOR_DOLLAR(penny, nickel, dime, quarter) < DOLLAR_VALUE: print 'the amount was less than a dollar' def CHANGE_FOR_DOLLAR(a, b, c, d): r = a*PENNY_VALUE + b*NICKEL_VALUE + c*DIME_VALUE + d*QUARTER_VALUE return r main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question