Hey all. I started taking the Coursera course Python for Everybody a few days ago, and have zero programming experience. I was working on an assignment where we need to calculate gross pay for OT hours worked, where at 40 hours you make regular pay, and after 40 you make 1.5 x pay (based on user input). I tried messing around to come up with something where in addition, if you work over 60 hours, those hours are then at 2 x times pay. This is what I have so far. Any ideas as to what I’m doing wrong? Thanks.
hrs = input(“Enter Hours:”)
hours = float(hrs)
rat = input(“Enter Rate:”)
rate = float(rat)
if hours > 40 :
othours = hours – 40
pay = (40 * rate) + (othours * rate * 1.5)
elif hours > 60:
dbltime = hours – 60
pay = (40 * rate) + (othours * rate * 1.5) + (dbltime * rate * 2)
else :
pay = hours * rate
print(pay)
submitted by /u/Visualplaybook_9975
[link] [comments]
r/learnpython Hey all. I started taking the Coursera course Python for Everybody a few days ago, and have zero programming experience. I was working on an assignment where we need to calculate gross pay for OT hours worked, where at 40 hours you make regular pay, and after 40 you make 1.5 x pay (based on user input). I tried messing around to come up with something where in addition, if you work over 60 hours, those hours are then at 2 x times pay. This is what I have so far. Any ideas as to what I’m doing wrong? Thanks. hrs = input(“Enter Hours:”) hours = float(hrs) rat = input(“Enter Rate:”) rate = float(rat) if hours > 40 : othours = hours – 40 pay = (40 * rate) + (othours * rate * 1.5) elif hours > 60: dbltime = hours – 60 pay = (40 * rate) + (othours * rate * 1.5) + (dbltime * rate * 2) else : pay = hours * rate print(pay) submitted by /u/Visualplaybook_9975 [link] [comments]
Hey all. I started taking the Coursera course Python for Everybody a few days ago, and have zero programming experience. I was working on an assignment where we need to calculate gross pay for OT hours worked, where at 40 hours you make regular pay, and after 40 you make 1.5 x pay (based on user input). I tried messing around to come up with something where in addition, if you work over 60 hours, those hours are then at 2 x times pay. This is what I have so far. Any ideas as to what I’m doing wrong? Thanks.
hrs = input(“Enter Hours:”)
hours = float(hrs)
rat = input(“Enter Rate:”)
rate = float(rat)
if hours > 40 :
othours = hours – 40
pay = (40 * rate) + (othours * rate * 1.5)
elif hours > 60:
dbltime = hours – 60
pay = (40 * rate) + (othours * rate * 1.5) + (dbltime * rate * 2)
else :
pay = hours * rate
print(pay)
submitted by /u/Visualplaybook_9975
[link] [comments]