gross = float(raw_input("Please enter your Gross Pay: ")) savings = (float(raw_input("Please enter the percent of savings you desire: ")) / 100) bill_sum = 0 bill_dic = {'rent' : (float(raw_input("Please enter the amount of Rent due: ")) / 2), 'utilities' : (0 / 2), 'car' : (307 / 2), 'insurance' : (157 / 2), 'school' : (100 / 2), 'gas' : (80 / 2), 'ntta' : (40 / 2), 'phone' : (45 / 2)} deduction_dic = {'invest' : 36.59, 'dental' : 5.08, 'gtl' : 0.18, 'medical' : 69.65, 'vision' : 0.92, 'medicare' : 16.59, 'federal' : 135.13, 'social_security' : 70.94} def pay_breakdown(gross, deduction_dic): deduction_total = 0 for item in deduction_dic: deduction_dic[item] = deduction_dic[item] / gross for item in deduction_dic: deduction_total += deduction_dic[item] return deduction_total def bill_calc(remainder, bill_sum, savings): difference = remainder - bill_sum product = difference * savings if (difference - product) >= 100: difference -= product return [difference, product] for item in bill_dic: bill_sum += bill_dic[item] remainder = gross - (gross * pay_breakdown(gross, deduction_dic)) test = bill_calc(remainder, bill_sum, savings) print "Amount for Savings: %s remaining amount: %s" % (test[1], test[0])
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