Python payroll calculator

Need support for your remote team? Check out our new promo! Select all Open in new window. IT issues often require sun magick personalized solution.

Why EE? Get Access.

Subscribe to RSS

Log In. Web Dev. NET App Servers. We help IT Professionals succeed at work. Calculate wages, time and a half, double time in python. Medium Priority.

Last Modified: Trying to learn programming and am grappling with this problem. How can I add to this code. Hence they get paid for at most 20 hours overtime at 1. Include overtime for hours over Start Free Trial. View Solution Only. Experts with Gold status have received one of our highest-level Expert Awards, which recognize experts for their valuable contributions.

Most Valuable Expert This award recognizes tech experts who passionately share their knowledge with the community and go the extra mile with helpful contributions. Top Expert This award recognizes someone who has achieved high tech and professional accomplishments as an expert in a specific topic. Commented: Gerwin Jansen Topic Advisor.

Author Commented: It still uses the enter 25 hours of overtime when it should just be the first Hopefully that makes sense.

Not the solution you were looking for? Getting a personalized solution is easy. Ask the Experts. But there are many ways you can solve this. Best is to start with pseudo code, test with a few special entries like 0, 40, 55, 60, 80 etc. After that you can keep pseudo code as comment and then write the real code. There you gomodified your code to give you the solution '''if-else example: calculate weekly wages -- alternate version''' def calcWeeklyWages totalHours, hourlyWage : '''Return the total weekly wages for a worker working totalHours, with a given regular hourlyWage.

SameekM: poster is learingthat's why I did not post a complete solution. See first line of original post: Trying to learn programming. Thanks, the learning is slow going :. No problem, keep at it, give pseudo code a try. Explore More Content.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It only takes a minute to sign up.

This is a calculator I'm working on. The ultimate goal is to calculate multiple payrolls before selecting to end the program, please review current version in that context. PSA: I'm a beginner. As you can see, input eval uates the input. Which is not very safe. Lets say you have some special information that no-one should know about. But you stored it in a variable. We with our 'elite haxor skillz', we could find out that information.

Bottom line input is badso bad that it got removed in Python3. If you are ok with using turnery operators you can re-write it, but your way is probably best.

Except for overtimeratethat should be part of overtime. If I were to re-write your code then it would be something like:. You could even opt for it not to be a function. Also you should add it to computePay as it would fit better there. In displayPay you may want to use str. They're very similar, so to change to str. As for main. Due to all the changes above I personally would recommend that you change it to 3 function calls. They are inputDatacomputePay and displayPay. Whilst you could merge it all into one function and keep everything simple, keeping IO away from logic is always good.

Just to note, you should always have functions declared and used as function. Note there is no space between the name and the brackets! Also as some languages allow - in names, it's always a good idea to put a space either side of operators. This prevents your code running if it's not the main file. Just so you know currently almost all your code is dead code It does nothing.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I'm writing a payroll calculator for school in python 3. The user input starts by asking for your name or "0" to quit the program.

I can't figure out how to get it to stop printing the payroll information after you end it. This is what I have so far. So I think I have got it.

Calculate wages, time and a half, double time in python

I have copied most of your code and it all works well. Let me explain my changes so if this helps you know why it works. First off I changed the method of defining when to end. I then left the print, but added a break. Thats the key here. Without the break, it just continues the loop after the "end report".

But with the break in place, it exits out of the loop after printing "end report". Learn more. Payroll Calculator in python Ask Question. Asked 3 years, 9 months ago. Active 26 days ago.

python payroll calculator

Viewed 16k times. Brandon Peavy Brandon Peavy 9 1 1 gold badge 1 1 silver badge 3 3 bronze badges. Active Oldest Votes. Would save me having to edit this haha. NicheQuiche NicheQuiche 72 6 6 bronze badges. Not a bad way to go. You can also get rid of end and just use while True: since you are expressly exiting the loop with break.

Also, you can get rid of the else: within the loop for the same reason: nothing in the loop after the break will happen if the break does. I made one as well. Here's mine in Python 3x. How much do you make per hour? Jonathan Jonathan 11 4 4 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.Create a simple calculator which can perform basic arithmetic operations like addition, subtraction, multiplication or division depending upon the user input. Approach :. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.

See your article appearing on the GeeksforGeeks main page and help other Geeks. Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below. Writing code in comment?

python payroll calculator

Please use ide. Ways to increment a character in Python How to print without newline in Python? Decision Making in Python ifif.

Approach : User choose the desired operation. Options 1, 2, 3 and 4 are valid. Two numbers are taken and an if…elif…else branching is used to execute a particular section. Using functions addsubtractmultiply and divide evaluate respective operations. Example : Please select operation - 1. Add 2. Subtract 3. Multiply 4. Python program for simple calculator. Function to add two numbers. Function to subtract two numbers. Function to multiply two numbers.

Function to divide two numbers. Take input from the user. Pushpanjali chauhan. Check out this Author's contributed articles. Improved By : priyankakarande. Load Comments.I have to create a python program for class- the instructions are- Write a payroll program that pays time and a half for anything over 40 hours. This should have 3 functions in addition to main. Which I did without the 3 funcitons. But now the teacher is hitting me with these instructions and I can't figure out how to seperate things to make him happy.

When I start to seperate functions I get errors, or nothing prints. Thank you very much, this is very helpful. I have the same assignment and this is what I have done:. I would be very appreciate if anybody can give me a hint. This is what I've done, but I dont know why it couldnot run. Please advice. I just started Python class for couple week, I am really appreciate all of your reference but its over my understanding. Thank you for your reply.

Honestly, I am feeling stupid now since I dont even understand why should I divide by ten in previous loop, this is the hint from my teacher. If the tens position is a "1" then it is a teens number and you would not print the ones position.

Ditto for tens position when it is zero, for the numbersetc. The first function asks the user how many total hours were worked and the pay rate and returns this information to main. These values must be validated. Hours worked must be at least 8 and no more than The second function calculates the regular hours and overtime hours and returns this information to main. A person might work less than 40 hours so you must allow for that situation.

The third function calculates the regular pay, regular hours times pay rate ; overtime pay, overtime hours times overtime pay rate and the total pay and returns this information to main. Main will then display this information on the screen like the sample below. Values will have to be passed and returned. Edited 6 Years Ago by TrustyTony : fixed formatting, code indention, watch out, do not post rubbish!

The theacher is right. Thank you. Hi Tony, Thank you for your reply. Edited 6 Years Ago by woooee. Getting Started: Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and adhere to our posting rules. Edit Preview. H1 H2.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It only takes a minute to sign up. This is a calculator I'm working on. The ultimate goal is to calculate multiple payrolls before selecting to end the program, please review current version in that context. PSA: I'm a beginner. As you can see, input eval uates the input. Which is not very safe. Lets say you have some special information that no-one should know about.

But you stored it in a variable. We with our 'elite haxor skillz', we could find out that information. Bottom line input is badso bad that it got removed in Python3. If you are ok with using turnery operators you can re-write it, but your way is probably best. Except for overtimeratethat should be part of overtime. If I were to re-write your code then it would be something like:. You could even opt for it not to be a function.

python payroll calculator

Also you should add it to computePay as it would fit better there. In displayPay you may want to use str. They're very similar, so to change to str. As for main. Due to all the changes above I personally would recommend that you change it to 3 function calls. They are inputDatacomputePay and displayPay.To calculate a paycheck start with the annual salary amount and divide by the number of pay periods in the year. This number is the gross pay per pay period. Subtract any deductions and payroll taxes from the gross pay to get net pay.

Don't want to calculate this by hand? The PaycheckCity salary calculator will do the calculating for you. PaycheckCity Payroll is an easy and affordable way to do your small business payroll. Select your state from the list below to see its hourly paycheck calculator. Want to add these calculators to your website?

Learn about our customizable calculators. Select a state to add state and local taxes. Check Date. Add Rate Remove Rate. Gross Pay YTD. Use W4. Step 2: Two Jobs. Step 3: Dependents Amount. Step 4a: Other Income. Step 4b: Deductions. Additional Federal Withholding.

Round Federal Withholding. Exempt from Federal. Exempt from FICA. Exempt from Medicare. Deduction Name. Year to Date Amount. Exempt from State. Exempt from Local. Add Deduction Remove Deduction. Clear Calculate. How do I complete a paycheck calculation? Still doing payroll by spreadsheets? Try 7 days free. State Hourly Paycheck Calculators. The calculators on this website are provided by Symmetry Software and are designed to provide general guidance and estimates. These calculators should not be relied upon for accuracy, such as to calculate exact taxes, payroll or other financial data.

Neither these calculators nor the providers and affiliates thereof are providing tax or legal advice. You should refer to a professional adviser or accountant regarding any specific requirements or concerns.