Exercise 4.6: Rewrite your pay computation with time-and-a-half for overtime
and create a function called computepay which takes two paramteters (hours and
rate).
Enter Hours: 45
Enter Rate: 10
Pay: 475.0
Python for Everybody: Exploring Data Using Python 3
by Charles R. Severance
def computepay(hours, rate):
if hours <= 40 :
return hours * rate
else :
return ((40 * rate) + ((hours - 40) * rate * 1.5))
hours = input("Enter Hours: ")
try:
hours = float(hours)
rate = input("Enter Rates: ")
rate = float(rate)
print("Pay: ", computepay(hours, rate))
except:
print("Error! please enter numeric input")
'PYTHON' 카테고리의 다른 글
Answer (5-01) for Python for Everybody by Charles R Severance (0) | 2019.09.23 |
---|---|
Answer (4-07) for Python for Everybody by Charles R Severance (0) | 2019.09.23 |
Answer (3-03) for Python for Everybody by Charles R Severance (0) | 2019.09.23 |
Answer (3-02) for Python for Everybody by Charles R Severance (0) | 2019.09.23 |
Answer (3-01) for Python for Everybody by Charles R Severance (0) | 2019.09.23 |