Python Forum
Problematic Assignment
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problematic Assignment
#1
Hello, I m stuck here, I dont know whats missing or whats wrong with it. Please, if anyoane have any suggestions, I literally cant continue. Thanks!
hrs = input("Enter Hours:")
h = float(hrs)
rate = input('Enter rate:')
r = float(rate)
if h<40:
    print (h * r)
elif h>40:
    r = r*float(1.5)
pay = h * r
print( pay)
The desire output is 498.75. The problem is thata I keep getting 708.75 and I have no idea why.
Reply
#2
You have only provided the output. Kindly provide the input values for the rate and hours.

Also enter the code within the proper tags so that its readable. Click on the insert python option and place the code within this.
Reply
#3
Please use proper code tags while coding, it is very difficult to understand your code otherwise. See BBCode for more info.
Also, please tell what have you tried, what are you supposed to do, what is the input you need to get your expected output, but what are you getting instead
Quote:You have only provided the output
@Pranav, no that is his code, not his output

(May-17-2020, 06:33 AM)EB22 Wrote: The desire output is 498.75. The problem is that I keep getting 708.75 and I have no idea why.

Well, it would be helpful if you showed us your full assignment
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#4
I agree with the above, but I think I see what is going on. You are applying the 1.5 overtime rate to the whole amount if the person goes over 40 hours, when you should only apply that to the excess over 40.

If I work 41 hours at $10 per hour, I should get 40*10 + 1*15, not 41*15.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020