## Why does this not work?

A forum for general discussion of the Python programming language.

### Why does this not work?

I need to write a program to do this, and I would like it to be done using the commands I have already used in the program but for some reason this does not want to work?

Write a program that asks the user for the number of hours worked this week and their hourly rate of
pay. The program is to calculate the gross pay.
If the number of hours worked is greater than 40, the extra hours are paid at 1.5 times the rate. The
program should display an error message if the number of hours worked is not in the range 0 to 60.

Code: Select all
hours = ("Number of hours worked: ")
pay = ("Hourly rate of pay: ")
if int(hours) < 40:
pay2 = (int(hours) * int(pay))
print("Gross pay = ", end=""),print(pay2)
if int(hours) > 40:
pay2 = (40 * (int(pay)) + ((int(hours) - (40)) * (int(pay)*(1.5))))
print("Gross pay = ", end=""),print(pay2)
if int(hours) < 0:
print("This value is too low for the range")
if int(hours) > 60:
print("This value is above the range")
Last edited by stranac on Thu Sep 19, 2013 5:16 pm, edited 1 time in total.
Reason: Added code tags, locked post
cramsteems

Posts: 10
Joined: Thu Sep 19, 2013 5:11 pm

### Re: Why does this not work?

Code: Select all
hours = input("Number of hours worked: ")
pay = input("Hourly rate of pay: ")
if int(hours) < 40:
pay2 = (int(hours) * int(pay))
print("Gross pay = ", end=""),print(pay2)
if int(hours) > 40:
pay2 = (40 * (int(pay)) + ((int(hours) - (40)) * (int(pay)*(1.5))))
print("Gross pay = ", end=""),print(pay2)
if int(hours) < 0:
print("This value is too low for the range")
if int(hours) > 60:
print("This value is above the range")
Join the #python-forum IRC channel on irc.freenode.net!

Yoriz

Posts: 1376
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

### Re: Why does this not work?

You're not getting the user's input at all.
You should use the input() function to do that.

There are other problems with your code, but this should get you started.
Friendship is magic!

R.I.P. Tracy M. You will be missed.

stranac

Posts: 1475
Joined: Thu Feb 07, 2013 3:42 pm

### Re: Why does this not work?

OMG how stupid of me totally didn't notice!

Thanks yoriz!
cramsteems

Posts: 10
Joined: Thu Sep 19, 2013 5:11 pm