Python Forum
compute gross pay - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: compute gross pay (/thread-4771.html)



compute gross pay - jamesuzo - Sep-07-2017

please give a runnable sample of your code with the full error text or a clear description of the problem

pay: 472.5 ← Mismatch

Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking the user input - assume the user types numbers properly.

hrs = input("Enter Hours:")
rate = input ("Enter Rate:")
xp = float (hrs) * float (rate)
print ("pay:", xp)


RE: compute gross pay - ichabod801 - Sep-07-2017

You're not paying the hours over 40 at 1.5 the hourly rate. You need to figure that into your calculation. I would put in an if statement to check if the hours are over 40, and then if they are, add the extra to xp.

And please use python tags for your code, see the BBCode link in my signature below for instructions.