【发布时间】:2019-09-29 19:07:57
【问题描述】:
当我进一步了解代码时,它告诉我“是”没有定义。代码询问用户他们工作了多长时间并计算代码。
我已尝试对该语句进行一些小的更改。它给了我同样的结果。
当用户回答“是”时;我想要代码计算总工资
Overtimeflag = 50
if Overtimeflag == 50:
Overtimeflag = True
Else:
Overtimeflag = False
Name = input('Whats your first and last name')
Address = input('Whats your address')
HoursWorked=float(input('How many years have you been working here'))
Overtime=float(input('how long did you work today'))
if HoursWorked > 40:
print('You are qualified for overtime pay')
elif Overtime >= 2:
Overtime = HoursWorked - 40
else:
print('In order to earn overtime, the user must have worked for at least 2 years')
grossPay =float(input('Whats your hourly rate'))
Overtimeflag =input('Did you work 50 hours this week')
##Calculate the gross pay with the following formula
if grossPay == Yes:
Overtime2 * grossPay * 2 + HoursWorked - Overtimeflag * grossPay
else:
print('You do not earn overtime due to lack of years of service')
【问题讨论】:
-
如果您发布您的实际代码会有所帮助...我们不是魔术师。
-
您的代码还有其他问题。您将
grossPay与Yes进行比较,但grossPay是一个浮点数(float(input('Whats your hourly rate')))。Overtime2是什么?
标签: python-3.x debugging logic