Skip to content

Instantly share code, notes, and snippets.

@KKarthikeya
Created August 16, 2015 04:19
Show Gist options
  • Save KKarthikeya/0696fe56a97c0699c3c5 to your computer and use it in GitHub Desktop.
Save KKarthikeya/0696fe56a97c0699c3c5 to your computer and use it in GitHub Desktop.
Write a program to prompt the user for hours and rate per hour using raw_input to compute gross pay. Award time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of time-and-a-half in a function called computepay() and use the function to do the computation. The function should return a valu…
def computepay(hours,rate):
if hours>40.0:
p = rate * 40.0
p = p+(1.5*rate*(hours-40))
else:
p = rate*hours
return p
hours = float(raw_input("Enter worked hours: "))
rate = float(raw_input("Enter Pay rate per hour: "))
print computepay(hours,rate)
@ShivamRai21
Copy link

ShivamRai21 commented Jul 28, 2020

This code is definitely gonna run on any platform.
Just try it once.

def computepay(h,r):
if h>40.0:
p=1.5 * float(r) * (h-40.0)+(40.0 * float(r))
else:
p=h*r
return p
hrs = input("enter hours:")
a=float (hrs)
rate = input("enter rate per hour:")
b=float(rate)
p=computepay(a,rate)
print("Pay",p)

@mihir16799
Copy link

help me my code is not running

@shamilhzm
Copy link

solution without def

hrs = input("Enter Hours:")
h = float(hrs)
rate = input("Enter Pay Rate:")
r = float(rate)
pay = hr
otpay = 40
r + (h-40)r1.5
if h<=40:
print(pay)
else:
print(otpay)

@samriddhitiwari
Copy link

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% working

Assignment 4 6

Thanks!!!!!!! a tonnnnn it really worked

@shivamgupta6588
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment