0

A small doubt

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).

17th May 2020, 7:45 AM
prasad jagdale
prasad jagdale - avatar
21 Réponses
0
17th May 2020, 8:43 AM
Abhay
Abhay - avatar
+ 4
Could it be indentation error? hrs = input("Enter Hours:") h = float(hrs) rate=input("Enter rate:") r= float(rate) if h<= 40: reg= h*r otp=(h-40)*(r*1.5) xp=reg+otp print(xp) else: xp=h*r print(xp)
17th May 2020, 7:53 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 3
prasad jagdale Indentation Problem. This is most generic problem in python. You should understand about it. if h<= 40: reg= h*r otp=(h-40)*(r*1.5) xp=reg+otp print(xp) else: xp=h*r print(xp)
17th May 2020, 7:54 AM
A͢J
A͢J - avatar
+ 1
prasad jagdale Ur fix I added some styling just ignore it Ur bug is indentation error Which means use of different no. Of spaces for every statement under a similar block https://code.sololearn.com/ckTlT7IHvu7S/?ref=app
17th May 2020, 7:57 AM
Abhay
Abhay - avatar
0
Where is your attempts?
17th May 2020, 7:49 AM
A͢J
A͢J - avatar
0
It is absolutely logical error
17th May 2020, 8:02 AM
Abhay
Abhay - avatar
0
prasad jagdale i m working on it wait a little bit
17th May 2020, 8:04 AM
Abhay
Abhay - avatar
0
They're answers were almost correct except the sign "<=40" in the first condition. Finally, you got it right ">=40" !
17th May 2020, 8:04 PM
Mikhail Malyshev
Mikhail Malyshev - avatar
- 1
Got it. Sorry for the trouble guys, and thanks for the help. hrs = input("Enter Hours:") h = float(hrs) rate=input("Enter rate:") r= float(rate) if h>=40: reg= h*r otp=(h-40)*(r*0.5) xp=reg+otp print(xp) else: xp=h*r print(xp)
17th May 2020, 8:08 AM
prasad jagdale
prasad jagdale - avatar
- 2
hrs = input("Enter Hours:") h = float(hrs) rate=input("Enter rate:") r= float(rate) if h<= 40: reg= h*r otp=(h-40)*(r*1.5) xp=reg+otp print(xp) else: xp=h*r print(xp)
17th May 2020, 7:50 AM
prasad jagdale
prasad jagdale - avatar
- 2
This code is showing error in line 10
17th May 2020, 7:50 AM
prasad jagdale
prasad jagdale - avatar
- 2
Now it is working but the answer is not correct
17th May 2020, 7:56 AM
prasad jagdale
prasad jagdale - avatar
- 2
The code is working but there is mismatch in answer. The answer should be 498.75 and it is coming as 472.5
17th May 2020, 8:00 AM
prasad jagdale
prasad jagdale - avatar
- 2
Yes indeed. But I want help in that part as well 😭
17th May 2020, 8:03 AM
prasad jagdale
prasad jagdale - avatar
- 2
Okay sir
17th May 2020, 8:05 AM
prasad jagdale
prasad jagdale - avatar
- 2
ATQ, if hrs = 45 and rate = 10.5 pay = 10.5 x 1.5 x 45 = 708.5 Not 498.5
17th May 2020, 8:09 AM
Abhay
Abhay - avatar
- 2
prasad jagdale Can u explain the Q. with a elaborated example Plzzz the same i absolutely helps u
17th May 2020, 8:11 AM
Abhay
Abhay - avatar
- 2
Sir in the problem we have to pay hourly rate upto 40 hours and after 40 hours 1.5 times the hourly rate. So that is the reason the code is that way . Nevermind
17th May 2020, 8:11 AM
prasad jagdale
prasad jagdale - avatar
- 2
Means upto 40 hours the pay will be rate times hours and after 40 hours pay will rate *hours* 1.5
17th May 2020, 8:13 AM
prasad jagdale
prasad jagdale - avatar
- 2
Thank you so much all for helping me in this problem ❤️
17th May 2020, 8:16 AM
prasad jagdale
prasad jagdale - avatar