Good evening! I am having a bit of trouble solutioning my homework. I'm supposed to write a script where I can do inputs and get back certain information YET it is asking for a variable that hasn't been declared and I don't know how to delcare it without actually giving it a figure.
EmployeeBonus.py - This program calculates an employee's productivity bonus.
initialize variables here.
bonus_1 = 50.00
bonus_2 = 75.00
bonus_3 = 100.00
bonus_4 = 200.00
employee_name = input("Enter employee's name: ")
shiftString = input("Enter number of shifts: ")
transactString = input("Enter number of transactions: ")
dollarString = input("Enter transactions dollar value: ")
numShifts = float(shiftString)
numTransactions = float(transactString)
dollarValue = float(dollarString)
Write your code here
score = (dollarValue / numTransactions) / numShifts
if score >= 200.0:
bonus = bonus_4
if score >= 70 and score <= 199:
bonus = bonus_3
if score >= 31 and score <= 69:
bonus = bonus_2
if score <= 50:
bonus = bonus_1
Output.
print("Employee Name:" + employee_name)
print("Employee Bonus: $" + str(bonus))
Error -
Enter employee's name: Kim Smith
Enter number of shifts: 25
Enter number of transactions: 75
Enter transactions dollar value: 40000.00
Employee Name:Kim Smith
Traceback (most recent call last):
File "/workspaces/9780357880876_pld-10e-python-e2683982-f328-4dd7-b897-6609573c97d1/chapter4/ex03/student/EmployeeBonus.py", line 32, in <module>
print("Employee Bonus: $" + str(bonus))
NameError: name 'bonus' is not defined. Did you mean: 'bonus_1'?
How can i declare bonus as a variable to avoid running into post error?
I should be able to fill out
Enter employee's name: Kim Smith
Enter number of shifts: 25
Enter number of transactions: 75
Enter transactions dollar value: 40000.00 and get back
Employee Name: Kim Smith
Employee Bonus: $50