import sys overtime_hours_ceil = 40 overtime_rate = 1.5 try: hours = raw_input('Enter hours worked:') hours = float(hours) except: print 'Error: Please enter hours using numeric digits only. Try again.' sys.exit(1) try: rate = raw_input('Enter rate worked:') rate = float(rate) except: print 'Error: Please enter rate using numeric digits only. Try again.' sys.exit(1) print 'Hours: ', hours print 'Rate : ', rate if hours > overtime_hours_ceil : pay_owed = ((hours - overtime_hours_ceil) * rate * overtime_rate) + (overtime_hours_ceil * rate) print 'Pay owed (normal rates) : ', (overtime_hours_ceil * rate) print 'Pay owed (overtime extra): ', ((hours - overtime_hours_ceil) * rate * overtime_rate) else : pay_owed = hours * rate print 'Pay owed: ', pay_owed
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