Overtime Pay Calculation in Python
hrs=float(input("Enter hours: "))
rt=float(input("Enter rate/h: "))
if hrs > 40:
overtime = hrs - 40
overpay=overtime*(rt*1.5)
payof40hrs=rt*40
pay=payof40hrs+overpay
else:
pay=rt*hrs
print("Pay:",pay)
# The same thing in function format
def computepay(hrs, rt):
if hrs > 40:
overtime = hrs - 40
overpay=overtime*(rt*1.5)
payof40hrs=rt*40
pay=payof40hrs+overpay
else:
pay=rt*hrs
return pay
hrs=float(input("Enter hours: "))
rt=float(input("Enter rate/h: "))
print("Pay",computepay(hrs, rt))
Comments
Post a Comment
Write something to CodeWithAbdur!