定义一个计算过程,工作6个月以内的奖金500元,6-12(含)个月每个月120元,12个月以上每个月180元,再定义一个信息输入,最后调用函数。
def bonus(month):
if month < 6:
money = 500
elif 6 < month <=12:
money = month * 120
else:
money = month * 180
return money
def info(name,month):
pay = bonus(month)
print('{} is working for {} months, the bonus is ${}'.format(name,month,pay))
name_in=input('Please input your name:')
month_in=int(input('How many months did you worked:'))
info(name_in,month_in)