Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the function to do the computation…
def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p
hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)
p = computepay(hr,rphr)
print(p)
@saydiburkhon

This comment has been minimized.

Copy link

@saydiburkhon saydiburkhon commented Apr 8, 2020

1.5 * r * (h - 40) + (40 *r) from computation , I get different figures , could you please explain how come it gives the 498.75

@Anurag98524

This comment has been minimized.

Copy link

@Anurag98524 Anurag98524 commented May 1, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print('Pay',p)

@Lynthepeoplee

This comment has been minimized.

Copy link

@Lynthepeoplee Lynthepeoplee commented May 4, 2020

def computepay(hrs, rate):
if hrs > 40:
p = (hrs - 40) * 1.5 * rate + 40 * rate
else:
p = hrs * rate
return p
h = input("Enter Hours:")
hrs = float(h)
r = input("Enter Rate:")
rate = float(r)
p = computepay(hrs, rate)
print("Pay", p)

@tarunkumararcot

This comment has been minimized.

Copy link

@tarunkumararcot tarunkumararcot commented May 19, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)

print("Pay",p)

@tarunkumararcot

This comment has been minimized.

Copy link

@tarunkumararcot tarunkumararcot commented May 19, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)

print("Pay",p)

This the right one..I got it right

@sedategrower

This comment has been minimized.

Copy link

@sedategrower sedategrower commented May 25, 2020

1.5 * r * (h - 40) + (40 *r) from computation , I get different figures , could you please explain how come it gives the 498.75

ok as per definition of the program pay rate for up to 40 hours is suppose x and above 40 hours is 1.5x . Divide this equation in 2 part 1st is (40 r) which compute the pay of 40 hours. 2nd part is 1.5 * r * (h - 40) which computes the pay for hours > 40. here h is 45 so divide in 40 + 5. for 40 hours pay rate is x and for 5 hours pay rate is 1.5x. total pay rate is payrate(40 hours) +payrate(hour>40) . so compute the 1st part 4010.50= 420 now compute 2nd part (45-40) 1.510.50 = 51.510.50=78.75 . now add 1st part and second part 420+78.75=498.75.
try is for 52 hours . 1st part 4010.50=420 and 2nd part (52-40)1.510.50=121.510.50=189. s0 answes is 1st part+ 2nd part = 420+189=609. try this value on your code

@Vishvesh482003

This comment has been minimized.

Copy link

@Vishvesh482003 Vishvesh482003 commented May 25, 2020

4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the function to do the computation…
def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)

It is the right answer

@Chhetri-9901

This comment has been minimized.

Copy link

@Chhetri-9901 Chhetri-9901 commented May 27, 2020

Can i get an explanation for the "time-and-a-half for the hourly rate for all hours worked above 40 hours" and how is that 1.5 coming?

@7744RB

This comment has been minimized.

Copy link

@7744RB 7744RB commented May 30, 2020

hours = input("Enter Hours:")
rate = input("Enter Rate:")

if int(hours) <= 40:
def computepay(hours, rate):
wages = int(hours) * float(rate)
return wages
x = computepay(hours, rate)
print("Pay: ") + str(x)
else:
overhours = int(hours) - 40
def computepay(overhours, rate):
wages = (int(overhours) * float(rate) * 1.5) + (40 * float(rate))
return wages
x = computepay(overhours, rate)
print("Pay",x)

@Lekhram96

This comment has been minimized.

Copy link

@Lekhram96 Lekhram96 commented May 31, 2020

def computepay(h,r):
if h>40:
pay=1.5r(h-40)+(40r)
else:
pay=h
r
return pay
hrs=input ("Enter Hours:")
hr=float (hrs)
rphrs=input ("Enter rate per hour:")
rphr=float (rphrs)

p=computepay(hr,rphrs)
print("pay",p)

@Droid-Rayhan

This comment has been minimized.

Copy link

@Droid-Rayhan Droid-Rayhan commented May 31, 2020

Please tell me what is the problem in this code? It runs but the result doesn't match.

def computepay(x,y):
return x*y
h= input('Enter Hours:')
r=input('Enter Payment Per Hour:')
fh=float(h)
fr=float(r)
p= computepay(fh,fr)
if fh<=40:
print('Pay',computepay(fh,fr))
elif fh>40:
print('Pay',computepay(fh,fr)+((fh-40)1.510.50))

@benopoku

This comment has been minimized.

Copy link

@benopoku benopoku commented Jun 4, 2020

#Bernard
hrs = input("Enter Hours:")
hr = float(hrs)
rts = input("Enter rate per hour:")
rt = float(rts)

def computepay(h,r):
if h > 40:
p = (40*r) + 1.5 * r * (h-40)
else:
p = h * r
return p

p = computepay(hr,rt)
print("Pay",p)

@Junaid20001

This comment has been minimized.

Copy link

@Junaid20001 Junaid20001 commented Jun 7, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print('Pay',p)

@Arjun-Biswas

This comment has been minimized.

Copy link

@Arjun-Biswas Arjun-Biswas commented Jun 11, 2020

hours= input("enter hours: ")
h= float(hours)
rate= input("enter rate: ")
r= float(rate)
def computepay(h,r):
if h<=40:
k= h*r
else:
k = (40 * r) + 1.5 * (h - 40) * r
return k
print("Pay",computepay(h,r))

@basildoesstuff

This comment has been minimized.

Copy link

@basildoesstuff basildoesstuff commented Jun 15, 2020

I got it right (indent properly

)
def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
return p
else:
p = h * r
return p
hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)

print("Pay "+ str(p))

@chaltidutta

This comment has been minimized.

Copy link

@chaltidutta chaltidutta commented Jun 15, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print(p)

i have done it,but saying error,but why??

@AmanRaut1111

This comment has been minimized.

Copy link

@AmanRaut1111 AmanRaut1111 commented Jun 17, 2020

def computepay(hours, rate) :
if hours > 40 :
reg = rate * hours
otp = (hours - 40.0) * (rate * 0.5)
pay = reg + otp
else:
pay = hours * rate
return pay
sh = input ("Enter Hours: ")
sr = input ("Enter rate : ")
fh = float(sh)
fr = float(sr)
xp = computepay(fh, fr)
print("Pay",xp)

-----------------------------100%work-----------------------------------

@AmanRaut1111

This comment has been minimized.

Copy link

@AmanRaut1111 AmanRaut1111 commented Jun 17, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print(p)

i have done it,but saying error,but why??

try this
def computepay(hours, rate) :
if hours > 40 :
reg = rate * hours
otp = (hours - 40.0) * (rate * 0.5)
pay = reg + otp
else:
pay = hours * rate
return pay
sh = input ("Enter Hours: ")
sr = input ("Enter rate : ")
fh = float(sh)
fr = float(sr)
xp = computepay(fh, fr)
print("Pay",xp)

@Nishagupta14

This comment has been minimized.

Copy link

@Nishagupta14 Nishagupta14 commented Jun 17, 2020

can anyone explain how 1.5 is coming for time-and-a half hourly hours.?

@Mansi612

This comment has been minimized.

Copy link

@Mansi612 Mansi612 commented Jun 19, 2020

shows error in line 4??

@AmanRaut1111

This comment has been minimized.

Copy link

@AmanRaut1111 AmanRaut1111 commented Jun 19, 2020

shows error in line 4??

what is an error ?

@tanishq-agarwal

This comment has been minimized.

Copy link

@tanishq-agarwal tanishq-agarwal commented Jun 20, 2020

Smallest code:
def computepay(hr,ra):

if hr<=40:
p=hrra
else:
p=(hr-40)1.5ra+(40
ra)
return p

hrs = input("Enter Hours:")
hr=float(hrs)
rate= input("Enter rate:")
ra= float(rate)
p = computepay(hr,ra)
print("Pay",p)

@himanshusengar00

This comment has been minimized.

Copy link

@himanshusengar00 himanshusengar00 commented Jun 21, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)
WORKING 100% ****

@aditimalkar

This comment has been minimized.

Copy link

@aditimalkar aditimalkar commented Jun 21, 2020

def computepay(hrs, rate):
if float(hrs) > 40:
p = 1.5 * float(r) * (float(h) - 40) + (40 * float(r))
else:
p = hrs * rate
return p

h = input("Enter Hours:")
hrs = float(h)
r = input("Enter Rate:")
rate = float(r)
p = computepay(hrs, rate)
print("Pay", p)

@Shubhamsingh09

This comment has been minimized.

Copy link

@Shubhamsingh09 Shubhamsingh09 commented Jun 21, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay", p)

100% right compiled and tested
Screenshot 2020-06-21 at 9 27 34 PM

@astha-29

This comment has been minimized.

Copy link

@astha-29 astha-29 commented Jun 24, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)

@LaibaMemon

This comment has been minimized.

Copy link

@LaibaMemon LaibaMemon commented Jun 25, 2020

image

why its showing be like that? anybody can help me out plz

@AmanRaut1111

This comment has been minimized.

Copy link

@AmanRaut1111 AmanRaut1111 commented Jun 25, 2020

image

why its showing be like that? anybody can help m

image

why its showing be like that? anybody can help me out plz

Try this

def computepay(hours, rate) :
if hours > 40 :
reg = rate * hours
otp = (hours - 40.0) * (rate * 0.5)
pay = reg + otp
else:
pay = hours * rate
return pay
sh = input ("Enter Hours: ")
sr = input ("Enter rate : ")
fh = float(sh)
fr = float(sr)
xp = computepay(fh, fr)
print("Pay",xp

@FouziaMozumder

This comment has been minimized.

Copy link

@FouziaMozumder FouziaMozumder commented Jun 25, 2020

------------This gonna work in a best way-------
def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)

@dileepachuthan

This comment has been minimized.

Copy link

@dileepachuthan dileepachuthan commented Jun 26, 2020

#check it out guys
def computepay(h,r):
if(h <= 40):
return h*r
else:
return 1.5 * h * r
hrs = input("Enter Hours:")
h = float(hrs)
rt = input("Enter rate:")
r = float(rt)
p = computepay(h,r)
print("Pay",p)

@HARSHITH-AH

This comment has been minimized.

Copy link

@HARSHITH-AH HARSHITH-AH commented Jun 26, 2020

IS THIS CORRECT?
def computepay(h,r):
if h<=40
p=h*r
else h>40
p= 1.5 * r * (h - 40) + (40 *r)
return p

hrs = input("Enter Hours:")
h=float(hrs)
rate=input("enter rate")
r=float(rate)
p = computepay(10,20)
print("Pay",p)

@rpkunn

This comment has been minimized.

Copy link

@rpkunn rpkunn commented Jun 28, 2020

image
why its showing be like that? anybody can help m

image
why its showing be like that? anybody can help me out plz

Case sensitive for "pay".. try "Pay"

@LaibaMemon

This comment has been minimized.

Copy link

@LaibaMemon LaibaMemon commented Jun 28, 2020

@Bunnyboy01

This comment has been minimized.

Copy link

@Bunnyboy01 Bunnyboy01 commented Jul 9, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p
h = float(input("Enter Hours: "))
r = float(input("Enter rate per hour: "))
p = computepay(h,r)
print("Pay",p)

@parndesai16

This comment has been minimized.

Copy link

@parndesai16 parndesai16 commented Jul 10, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay", p)

#i got it right
#100%working

@designeranup

This comment has been minimized.

Copy link

@designeranup designeranup commented Jul 10, 2020

#This code will be 100% working
def computepay(h, r) :
if h > 40 :
p = 40 * r + (h - 40) * 1.5 * r
else :
p = h * r
return p
h = float(input("Enter Hours"))
r = float(input("Enter Rate"))
p = computepay(h, r)
print("Pay", p)

@piston97

This comment has been minimized.

Copy link

@piston97 piston97 commented Jul 16, 2020

def computepay(hrs,rph):
if hrs < 40:
gp = rph * hrs
return gp
elif hrs > 40:
gp = 1.5 * r * (h - 40) + (40 *r)
return gp

h = float(input('enter the hours '))
r = float(input('enter the rate per hour '))
hrs = h
rph = r
p = computepay(h,r)
print('Pay',p)

@Garv44

This comment has been minimized.

Copy link

@Garv44 Garv44 commented Jul 16, 2020

image

why its showing be like that? anybody can help me out plz

P is in "CAPS" in PAY

@som983

This comment has been minimized.

Copy link

@som983 som983 commented Jul 20, 2020

def computepay(h,r):
if h>40:
p=(1.5*(h-40)r)+(40r)
else:
p=40*r
return p

hrs =input("Enter Hours:")
h=float(hrs)
rate =input("Enter rate per hour:")
r=float(rate)
p = computepay(h,r)
print("Pay",p)

@som983

This comment has been minimized.

Copy link

@som983 som983 commented Jul 20, 2020

this is working perfectly.try it

@mehreen-khan

This comment has been minimized.

Copy link

@mehreen-khan mehreen-khan commented Jul 20, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay", p)

the above code gave an error of - Pay None and if checked with hours less than 40, it gives out atleast an answer.

on the otherhand, I made it work by slightly making some changes-
def computepay(h,r):
if h<=40:
p= hr
else:
p = (40
r)+1.5*(h-40)*r
return p
hrs = input("Enter Hours:")
hr = float(hrs)
rphrs =("Enter rate per hour")
rphr = float(rphrs)
p = computepay(hr,rphr)
print("Pay",p)

Can somebody help me figure, why the earlier code is not working properly.

@akashnakod

This comment has been minimized.

Copy link

@akashnakod akashnakod commented Jul 21, 2020

hrs = input("Enter Hours:")
hra=float(hrs)
rate=input("Enter rate:")
raa=float(rate)

if hra<=40:
def computepay(hra,raa):
multiply=hra*raa
return multiply

else:
def computepay(hr,ra):
hr=hraraa
ra=(hra-40.0)
(raa*0.5)
p=hr+ra
return p

p = computepay(hra,raa)
print("Pay",p)

@JoseLuis-Luna

This comment has been minimized.

Copy link

@JoseLuis-Luna JoseLuis-Luna commented Jul 27, 2020

def computepay(h,r):

if h > 40:
    p= (40*r)+(h-40)*(1.5*r)
    
else:
    p= h*r
    

return p

hrs = input("Enter Hours:")
hr= float (hrs)

rate = input ("Enter Rate:")
rt= float(rate)

p = computepay(hr,rt)

print("Pay",p)

@iyashjayesh

This comment has been minimized.

Copy link

@iyashjayesh iyashjayesh commented Jul 30, 2020

def computepay(hours,rate):
if hours>40.0:
p = 1.5rate(hours-40) +(40rate)
else:
p = rate
hours
return p

hours=input("Enter Hours:")
hour= float(hours)
rphrs = input("Enter rate per hours:")
rphr = float(rphrs)

p= computepay(hour,rphr)
print("Pay:",p)

@pushiko28

This comment has been minimized.

Copy link

@pushiko28 pushiko28 commented Aug 11, 2020

1.5 * r * (h - 40) + (40 *r) from computation , I get different figures , could you please explain how come it gives the 498.75

is because you should use 0.5 (the midle with decimals) and not 1.5.

@jonbarba

This comment has been minimized.

Copy link

@jonbarba jonbarba commented Aug 14, 2020

#Many people are getting this wrong because they keep multiplying the overtime rate by 1.5 you need to multiply it by 0.5
def computepay(r):
if h > 40:
pays = (h - 40) * (0.5 * r) + (h * r)
return pays
elif h <= 40:
pays = h * r
return pays

hrs = input("Enter Hours: ")
h = float(hrs)
rate = input("Enter rate per hour: ")
r = float(rate)

print("Pay",computepay(r))

@NaelZaino

This comment has been minimized.

Copy link

@NaelZaino NaelZaino commented Aug 27, 2020

I used this code and it worked:

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

h = input("Enter Hours:")
h = float(h)
r = input("Enter rate per hour:")
r = float(r)

p=computepay(h,r)
print("Pay",p)

@NaelZaino

This comment has been minimized.

Copy link

@NaelZaino NaelZaino commented Aug 27, 2020

you can also make it shorter by combining the float and input together like the following:

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

h = float(input("Enter Hours:"))
r = float(input("Enter rate per hour:"))

p=computepay(h,r)
print("Pay",p)

@NaelZaino

This comment has been minimized.

Copy link

@NaelZaino NaelZaino commented Aug 27, 2020

image

why its showing be like that? anybody can help me out plz

change print "pay" to capital P

@WardaLiaqat01

This comment has been minimized.

Copy link

@WardaLiaqat01 WardaLiaqat01 commented Sep 2, 2020

#4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the function to do the computation. The function should return a value. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking the user input unless you want to - you can assume the user types numbers properly. Do not name your variable sum or use the sum() function.

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rat = input("Enter Rate per hour:")
rph = float(rat)
p = computepay(hr,rph)
print("Pay",p)

@bhartimeena

This comment has been minimized.

Copy link

@bhartimeena bhartimeena commented Sep 8, 2020

shows error in line 4??

what is an error ?

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print(p)

@bhartimeena

This comment has been minimized.

Copy link

@bhartimeena bhartimeena commented Sep 8, 2020

you should try this it's work 100%%%%%

@araujolaura

This comment has been minimized.

Copy link

@araujolaura araujolaura commented Sep 14, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)

you're welcome!

@Nephy2911

This comment has been minimized.

Copy link

@Nephy2911 Nephy2911 commented Sep 15, 2020

def computepay(h,r):
if h > 40:
p = 0.5 * r * (h-40) + (h * r)
else:
p = h * r
return p

hrs = input("Enter Hours: ")
hr = float(hrs)
rate = input("Enter Rate: ")
rte = float(rate)
p = computepay(hr,rte)

print("Pay",p)

@bhartimeena

This comment has been minimized.

Copy link

@bhartimeena bhartimeena commented Sep 16, 2020

shows error in line 4??
Yeah same error I got but when I give a tab after if and else statement it's run perfectly.

@darshanghadi007

This comment has been minimized.

Copy link

@darshanghadi007 darshanghadi007 commented Sep 24, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)

@Thrinesh15

This comment has been minimized.

Copy link

@Thrinesh15 Thrinesh15 commented Sep 30, 2020

Guys can anyone send the correct code for the following question
Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours.
The output should be 498.75

@ironemin1k

This comment has been minimized.

Copy link

@ironemin1k ironemin1k commented Oct 5, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay", p)

#Guys! just add a space last line. don't forget this assigment very sensitive.

@Thrinesh15

This comment has been minimized.

Copy link

@Thrinesh15 Thrinesh15 commented Oct 5, 2020

Thank you So much

@Harsha4747

This comment has been minimized.

Copy link

@Harsha4747 Harsha4747 commented Oct 9, 2020

def computepay(h,r):
if h>40:
return
40r+(h-
40)r1.5
else:
return h
r
hrs=float(input("enter hours:")
r=float(input("enter rate per hour:")
p=computepay(hrs,r)
print("pay",p)

@Harsha4747

This comment has been minimized.

Copy link

@Harsha4747 Harsha4747 commented Oct 9, 2020

Coming error

@Harsha4747

This comment has been minimized.

Copy link

@Harsha4747 Harsha4747 commented Oct 9, 2020

Thank you So much
Bro coming error

@bhartimeena

This comment has been minimized.

Copy link

@bhartimeena bhartimeena commented Oct 9, 2020

Thank you So much
Bro coming error

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)

you can try this!!

@Nephy2911

This comment has been minimized.

Copy link

@Nephy2911 Nephy2911 commented Oct 13, 2020

@arjunrajapeta

This comment has been minimized.

Copy link

@arjunrajapeta arjunrajapeta commented Oct 29, 2020

def computepay(hrs,rate):
if float(hrs) > 40:
pay = (40*float(rate)) + (float(hrs) -40) * float(rate) * 1.5
return pay
else:
pay = float(hrs)*float(rate)
return pay
hrs = input("Enter Hours:")
rate = input("Enter Rate:")
p = computepay(hrs,rate)
print("Pay" ,p)

@luissantaanna

This comment has been minimized.

Copy link

@luissantaanna luissantaanna commented Nov 3, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h-40) + (40*r)
else:
p = h * r
return p
hrs = input("Enter Hours: ")
h = float(hrs)
rate = input("Enter Rate: ")
r = float(rate)

p = computepay(h,r)
print("Pay",p)

@Sohanaafroz955

This comment has been minimized.

Copy link

@Sohanaafroz955 Sohanaafroz955 commented Nov 4, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)

@Laksara1997

This comment has been minimized.

Copy link

@Laksara1997 Laksara1997 commented Nov 23, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)

this is right answer

@MR-Robot2001

This comment has been minimized.

Copy link

@MR-Robot2001 MR-Robot2001 commented Nov 25, 2020

def computepay(h,r):
if h > 40:
p = 1.5 * r * (h - 40) + (40 *r)
else:
p = h * r
return p

hrs = input("Enter Hours:")
hr = float(hrs)
rphrs = input("Enter rate per hour:")
rphr = float(rphrs)

p = computepay(hr,rphr)
print("Pay",p)

//Perfect code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.