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).
21 Answers
0
prasad jagdale Two logical error
I stated them in code
https://code.sololearn.com/ckTlT7IHvu7S/?ref=app
+ 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)
+ 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)
+ 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
0
Where is your attempts?
0
It is absolutely logical error
0
prasad jagdale i m working on it wait a little bit
0
They're answers were almost correct except the sign "<=40" in the first condition. Finally, you got it right ">=40" !
- 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)
- 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)
- 2
This code is showing error in line 10
- 2
Now it is working but the answer is not correct
- 2
The code is working but there is mismatch in answer. The answer should be 498.75 and it is coming as 472.5
- 2
Yes indeed. But I want help in that part as well 😭
- 2
Okay sir
- 2
ATQ,
if hrs = 45 and rate = 10.5
pay = 10.5 x 1.5 x 45
= 708.5
Not 498.5
- 2
prasad jagdale Can u explain the Q. with a elaborated example
Plzzz the same i absolutely helps u
- 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
- 2
Means upto 40 hours the pay will be rate times hours and after 40 hours pay will rate *hours* 1.5
- 2
Thank you so much all for helping me in this problem ❤️