如何解决支付计算器 - 不支持的操作数
我一直在练习使用函数,但我不明白为什么 Python 建议我的一个变量是“nonetpye” - 任何建议都会很棒。
我的代码如下:
def gethoursandrate():
hours = -1
rate = -1
while hours < 0 or hours > 60:
hours = int(input('Please enter the number of hours worked: '))
hours = int(hours)
while rate < 0:
rate = input('Please enter the hourly rate of pay: £')
rate = float(rate)
return hours,rate
def calculatebasicpay(hours,rate):
basicpay = 0
if hours > 40:
hours = 40
basicpay = hours * rate
return basicpay
def calculateovertimepay(hours,rate):
overtimepay = 0
overtimehours = 0
if hours > 40:
overtimehours = hours - 40
overtimepay = overtimehours * rate * 1.5
def displaytotalpay(totalpay):
totalpay = round(totalpay,2)
print('Pay due for the week is: £{0}'.format(totalpay))
print('\n Pay Calculator \n')
basicpay = 0
overtimepay = 0
hours,rate = gethoursandrate()
basicpay = calculatebasicpay(hours,rate)
overtimepay = calculateovertimepay(hours,rate)
totalpay = basicpay + overtimepay
displaytotalpay(totalpay)
This is what I get when I run the code
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。