Instructions:
Add radio button options for filing status to the tax calculator program of Project 1. The user selects one of these options to determine the tax rate. The Single option’s rate is 20%. The Married option is 15%. The Divorced option is 10%. The default option is Single. Be sure to use the field names provided in the comments in your starter code.
Given Code:
It also gives us the code for a module but that is like 3000 lines long and we dont touch that
"""
File: taxformwithgui.py
Project 8.6
A GUI-based tax calculator.
Computes and prints the total tax, given the income and
number of dependents (inputs), and a standard deduction of
$10,000, an exemption amount of $3,000, and tax rates of
20% for Single
15% for Married
10% for Divorced
"""
from breezypythongui import EasyFrame
class TaxCalculator(EasyFrame):
"""Application window for the tax calculator."""
def __init__(self):
"""Sets up the window and the widgets."""
EasyFrame.__init__(self, title = "Tax Calculator")
# Label and field for the income
# (self.incomeField)
# Label and field for the number of dependents
# (self.depField)
# Radio buttons for filing status
# Button group (self.statusGroup)
# Option for single (self.single)
# Option for married (self.married)
# Option for divorced (self.divorced)
# The compute button
# Label and field for the tax
# (self.taxField)
# The event handler method for the button
def computeTax(self):
"""Obtains the data from the input field and uses
them to compute the tax, which is sent to the
output field (taxField)."""
pass
def main():
TaxCalculator().mainloop()
if __name__ == "__main__":
main()
# import tkinter for python gui elements
from tkinter import *
# function definition
def tax():
# assuming some amount to find the tax amount
amount = 35000
# if the selected option is 'single' then get 20% of assumed amount
if var.get() == 1:
tax_amt = 0.2 * amount
# if 'married' then 15% of assumed amount
elif var.get() == 2:
tax_amt = 0.15 * amount
# if divorced then 10% of assumed amount
elif var.get() == 3:
tax_amt = 0.1 * amount
# some display text
disp = "Taxable amount based on the selection is : " + str(tax_amt)
# set the label (which is created in the following steps) with the display text
label.config(text = disp)
# prepare a root window
root = Tk()
# name the root window
root.title("Tax calculator")
# mention the dimension of root window
root.geometry("300x200")
# initialize the variable as integer
var = IntVar()
# set the integer value to 1 i.e, first radio button selection by default
var.set(1)
# create buttons and place them in window as required
R1 = Radiobutton(root, text = "Single", variable = var, value = 1)
R1.place(x=50,y=50)
R2 = Radiobutton(root, text = "Married", variable = var, value = 2)
R2.place(x=50,y=80)
R3 = Radiobutton(root, text = "Divorced", variable = var, value = 3)
R3.place(x=50,y=110)
# create button and call the function when this button clicked
calculate_button = Button(root, text="Calculate", command=tax)
calculate_button.place(x=50, y=140)
# create another button to close the window
quit_button = Button(root, text="Quit", command=root.quit)
quit_button.place(x=130, y=140)
# create a label and place it so that the display text in window is displayed as expected
label = Label(root)
label.place(x=20, y=20)
# call mainloop() to start the event
root.mainloop()
output:
After selecting some radio button :
Instructions: Add radio button options for filing status to the tax calculator program of Project 1....
Add radio button options for filing status to the tax calculator program of Project 1. The user selects one of these options to determine the tax rate. The Single option’s rate is 20%. The Married option is 15%. The Divorced option is 10%. The default option is Single. For the calculations from Project 1, I was gonna use this. TAX_RATE = 0.20 STANDARD_DEDUCTION = 10000.0 DEPENDENT_DEDUCTION = 3000.0 # Request the inputs gross Income = float(input("Enter the gross income: "))...
X Programming Exercise 8.6 | Instructions breezypythongui.py taxformwithgui.py + Q Desktop + ve Add radio button options for filing status to the tax calculator program of Project 1. The user selects one of these options to determine the tax rate. The Single option's rate is 20%. The Married option is 15%. The Divorced option is 10%. The default option is Single. 1 2 File: taxformwithgui.py 3 Project 8.6 4 A GUI-based tax calculator. 5 6 Computes and prints the total...
Programming Exercise 8.3 | Instructions Write a GUI-based program that allows the user to convert temperature values between degrees Fahrenheit and degrees Celsius. The interface should have labeled entry fields for these two values. breezypythongui.py temperatureconvert... + 1 2 File: temperatureconverter.py 3 Project 8.3 4 Temperature conversion between Fahrenheit and Celsius. 5 Illustrates the use of numeric data fields. 6 • These components should be arranged in a grid where the labels occupy the first row and the corresponding fields...
Zybooks 11.12 LAB*: Program: Online shopping cart (continued) Python 3 is the code needed and this is in Zybooks Existing Code # Type code for classes here class ItemToPurchase: def __init__(self, item_name="none", item_price=0, item_quantity=0): self.item_name = item_name self.item_price = item_price self.item_quantity = item_quantity # def __mul__(self): # print_item_cost = (self.item_quantity * self.item_price) # return '{} {} @ ${} = ${}' .format(self_item_name, self.item_quantity, self.item_price, print_item_cost) def print_item_cost(self): self.print_cost = (self.item_quantity * self.item_price) print(('{} {} @ ${} = ${}') .format(self.item_name, self.item_quantity, self.item_price,...
Comprehensive Income Tax Course: Module 1 4. Randy turned 16 last year and had his first summer job. Even though his parents are claiming him as a dependent he wants to file a return in order to get his refund. He receives his W-2 and decides he can do his own return using form 1040-EZ. Which of the following information is not found on a Form W-2? a) The taxpayer’s Social Security number b) The taxpayer’s wages, tips and other...