一家公司决定向员工发放奖金。男性工人可获得5%的奖金,女性工人可获得10%的奖金。如果员工的工资低于10000,则该员工将获得2%的额外奖金。
计算工资以及必须提供的奖金。
我的代码如下:
a = input('Enter your name here: ')
b = int(input('your salary here: '))
c = input('your gender here (M/F) : ')
if b < 10000 and c == 'M':
print(str(a) + ' your salary with bonus is ' + str(b * 1.07))
elif b < 10000 and c == 'F':
print(str(a) + ' your salary with bonus is ' + str(b * 1.12))
if b >= 10000 and c == 'M':
print(str(a) + ' your salary with bonus is '+ str(b * 1.05))
elif b >= 10000 and c=='F':
print(str(a) + ' your salary with bonus is '+ str(b * 1.1))
答案 0 :(得分:0)
好吧,你不能只输入:
if b<10000 and c=='M' :
# code
else:
b<10000 and c=='F'
如果要检查两个条件,则需要两个if,例如:
if b<10000 and c=='M' :
# code
else:
if b<10000 and c=='F' :
# code