What is wrong with my code?

python

#1



create a python program below that prompts the user for their hourly pay rate and the number of hours they worked for the week and computes their pay amount. Any hours worked over 40 are paid at time-and-a-half (1.5 times the normal hourly rate).


Replace this line with your code.

hours=raw_input("Enter number of hours worked:")
payrate=raw_input("Enter the hourly wage:")
extrahours = hours - 40
overtime = payrate * 1.5 * extrahours

if hours <= 40:
pay = payrate * hours
elif hours > 40:
pay = 40 * payrate + overtime
else:
print "Invalid entry, please start over."

print "You should get paid around % dollars." %(pay)


#2

raw_input stores as string, you might want to convert to integer (int()) or float (float()), string math sucks.

and one small detail for later: always validate user input


#3

dumb question.... how do i go about converting my strings to the (int())?


#4

int() is the function call you need for the conversion, so the argument provided will be converted to a integer:

print int("3")

#5

hours=raw_input("Enter number of hours worked:")
return int(hours)
payrate=raw_input("Enter the hourly wage:")
return int(payrate)

so now that I do this the error of " File "python", line 2
SyntaxError: 'return' outside function"
keeps coming up...


#6

why do you use return? raw_input() is also a function call, yet you stored the result of this in a variable, why can't you do the same for int()?


#7

i got it now.. thank you very very much!!


#8