我是python的新手,对我正在研究的python练习有疑问! 费率为10.5,小时为45小时。支付应该是498.75美元,但我的代码保持显示551.25美元......
我错过了什么吗?
def computepay(hrs, rate):
if hrs <=40:
pay = hrs * rate
elif hrs > 40:
pay = ((hrs-40)*1.5*rate) + (hrs*rate)
return pay
hrs = float(raw_input('Enter hours '))
print computepay(hrs, 10.5)
答案 0 :(得分:0)
def computerpay(小时,费率): 如果小时<= 40: pay = hrs * rate elif hrs&gt; 40: pay =((hrs-40)* 1.5 * rate)+(40 * rate) 退货
hrs = float(raw_input(&#39;输入小时数&#39;)) print computerpay(小时,10.5)