Create your own salary paycheck calculator written in python
This is a simple script that I created to calculate how much I was going to make either each week or month when I was working from multiple locations. In this script I’m using a dictionary to store the different tax rates from Arizona and New York. Feel free to modify the states and rates, to get an accurate return from the salary paycheck calculator.
Download the Salary Paycheck Calculator on github.
How It works
The script is broken up into two functions. I’ll explain how each one works.
First thing the calculations function does is ask for your salary and stores it as an integer.
The next line asks the user to choose which state they are from. Feel free to modify this line to add your state. The \n is an escape character in python. It shows the output in a new line. Think of it like hitting the enter key.
Next we have the states variable which stores the state and tax rate in a dictionary. A dictionary is a collection which is unordered, changeable and indexed. In Python, dictionaries are written with curly brackets, and they have keys and values. The state is the key and the value is the state tax percentage. I set 1 for Arizona at 17 percents and 2 for New York at 27 percent. Feel free to change the dictionary to give you a more accurate return.
Now we take the input from the state that we were in and get the value(state tax percentage) from the dictionary and store the result in state_tax variable.
The next 4 lines calculate the weekly, biweekly, and monthly return after taxes, then prints them out on separate lines.
Lastly the script asks the user if they would like to calculate the return for another salary. If yes, then the the restart() function is called, which calls the calculations() function and starts the process all over. If no, then the script closes.
Thanks for reading. Feel free to leave a comment below with any questions or a function you were able to create.
Turn into a Python Pro!
Come on over and take a look at “Automate the Boring Stuff with Python: Practical Programming for Total Beginners“. If you’ve ever spent hours renaming files or updating hundreds of spreadsheet cells, you know how tedious tasks like these can be. But what if you could have your computer do them for you?
In Automate the Boring Stuff with Python, you’ll learn how to use Python to write programs that do in minutes what would take you hours to do by hand—no prior programming experience required. Once you’ve mastered the basics of programming, you’ll create Python programs that effortlessly perform useful and impressive feats of automation to:
–Search for text in a file or across multiple files
–Create, update, move, and rename files and folders
–Search the Web and download online content
–Update and format data in Excel spreadsheets of any size
–Split, merge, watermark, and encrypt PDFs
–Send reminder emails and text notifications
–Fill out online forms
This post “Salary Paycheck Calculator In Python” is located under the Programming Category
Learn how to Create a Website status monitor in Python!