Home Work Assignment

+2 Sunday Akinduro · January 23, 2015
for i in range(4, 100, 4):

print (i)

Post a Reply

Replies

- page 2
Oldest  Newest  Rating
0 Sunday Akinduro · February 7, 2015
Thanks Nishant,

But I could only see part of the code you posted in your reply.
0 Nishant Kumar Thakur · February 9, 2015
Somehow the website truncated my code. I am posting it here again:-

from Tkinter import *

root = Tk()
root.title('Pay Calculator')
frame = Frame(root)
frame.grid()


def calculate_pay(gross_pay, pension, life_assur):
    annual_tax_payable = (12 * float(gross_pay)) - (
        200000 + (0.2 * 12 * float(gross_pay)) + (12 * float(pension + life_assur)))
    if annual_tax_payable <= 0:
        monthly_tax_payable = (0.01 * 12 * gross_pay) / 12
        print(format(monthly_tax_payable, "8,.2f"))
    elif 0 < annual_tax_payable <= 300000:
        monthly_tax_payable = (0.07 * annual_tax_payable) / 12
        print(format(monthly_tax_payable, "8,.2f"))
    elif 300000 < annual_tax_payable <= 600000:
        monthly_tax_payable = ((300000 * 0.07) + ((annual_tax_payable - 300000) * 0.11)) / 12
        print(format(monthly_tax_payable, "8,.2f"))
    elif 600000 < annual_tax_payable <= 1100000:
        monthly_tax_payable = ((300000 * 0.07) + (300000 * 0.11) + ((annual_tax_payable - 600000) * 0.15)) / 12
        print(format(monthly_tax_payable, "8,.2f"))
    elif 1100000 < annual_tax_payable <= 1600000:
        monthly_tax_payable = ((300000 * 0.07) + (300000 * 0.11) + (500000 * 0.15) + (
            (annual_tax_payable - 1100000) * 0.19)) / 12
        print(format(monthly_tax_payable, "8,.2f"))
    elif 1600000 < annual_tax_payable <= 3200000:
        monthly_tax_payable = ((300000 * 0.07) + (300000 * 0.11) + (500000 * 0.15) + (500000 * 0.19) + (
            (annual_tax_payable - 1600000) * 0.21)) / 12
        print(format(monthly_tax_payable, "8,.2f"))
    elif annual_tax_payable > 3200000:
        monthly_tax_payable = ((300000 * 0.07) + (300000 * 0.11) + (500000 * 0.15) + (500000 * 0.19)+(1600000 * 0.21) + (
            (annual_tax_payable - 3200000) * 0.24)) / 12
        print(format(monthly_tax_payable, "8,.2f"))
    else:
        print('No tax due')
        monthly_tax_payable = 0
        
    return format(monthly_tax_payable, "8,.2f")

def getInputAndSetOutputOnUI():
    gross_pay = float(gross_payEntry.get())
    pension = float(pensionEntry.get())
    life_assurance_contri = float(life_assuranceEntry.get())
    monthly_tax_payable = calculate_pay(gross_pay, pension, life_assurance_contri)
    resultString.set("Monthly Tax : "+ monthly_tax_payable)
    
    

gross_payEntry = Entry(frame, text="Enter Monthly Gross Pay")
gross_payEntry.grid(row=0, column=1)
gross_payLabel = Label(frame, text="Monthly Gross Pay=NGN")
gross_payLabel.grid(row=0, column=0, sticky=E)

pensionEntry = Entry(frame, text='Monthly Pension Contribution')
pensionEntry.grid(row=1, column=1)
pensionLabel = Label(frame, text="Monthly Pension=NGN")
pensionLabel.grid(row=1, column=0, sticky=E)

life_assuranceEntry = Entry(frame, text='Monthly Life Assurance Contribution')
life_assuranceEntry.grid(row=2, column=1)
life_assuranceLabel = Label(frame, text="Monthly Life Assurance Contribution=NGN")
life_assuranceLabel.grid(row=2, column=0, sticky=E)

monthly_tax_payableButton = Button(frame, text="Monthly Tax Payable", command=getInputAndSetOutputOnUI)
monthly_tax_payableButton.grid(row=3, column=1, sticky=E)

resultString = StringVar()
resultString.set("Enter details and click button to get Monthly Tax")
resultField = Label(frame, textvariable=resultString)
resultField.grid(row=3, column=0, sticky=E)

root.mainloop()
0 Sunday Akinduro · March 28, 2015
@Nishant Kumar Thakur, thanks for your input and time.
  • 1
  • 2

Python

107,335 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator