Reputation: 11
Hi I'm new to python an am trying to create a program that would allow me to calculate the incentives of given employees based on their sales code. Each employee has a specific target to achieve. The target may be achieved or may not be. I have included the sales code and their corresponding target in an array which all line up to each other (the first element in salescode array has the target which is in the first element of the targets array). The achievement is inputted which is then divided by the target in the array based on the inputted sales code. this value is then given 4 if conditions to see what sort an incentive the individual gets.
The calculation I require is : percent=achievement/targets How do I make it so that it calculates the above by traversing through the salescode and targets array (finding which one lines up in order to calculate it)?
salescode= [102,103,104,106,107,119,122,125,131,135,141,164,124,163,162]
targets=[3000000.00,4000000.00,3000000.00,3000000.00,3000000.00,4000000.00,2000000.00,2000000.00,2000000.00,3000000.00,2000000.00,3000000.00,2000000.00,2000000.00,2000000.00]
print(salescode)
print(targets)
sales=input("Enter\n")
achievement=input("Enter the Acheivement\n")
for sales in range(len(salescode)):
percent=float(achievement)/float(targets)
if per>=2.50:
print(" Incentive "+(float(achievement[x])*0.0225))
elif per>=2.00:
print(" Incentive "+(float(achievement[x])*0.002))
elif per>=1.50:
print(" Incentive "+(float(achievement[x])*0.0175))
elif per>=1.00:
print(" Incentive "+(float(achievement[x])*0.001))
elif per<=0.99:
print("Target Not Achieved")
Upvotes: 1
Views: 745
Reputation: 48
in salescode for loop you can get index and using this index you can get value of targets
salescode= [102,103,104,106,107,119,122,125,131,135,141,164,124,163,162]
targets=[3000000.00,4000000.00,3000000.00,3000000.00,3000000.00,4000000.00,2000000.00,2000000.00,2000000.00,3000000.00,2000000.00,3000000.00,2000000.00,2000000.00,2000000.00]
print(salescode)
print(targets)
sales=input("Enter\n")
achievement=input("Enter the Acheivement\n")
for sales in range(len(salescode)):
getoutput =percetagefind(achievement,targets[sales])
print(getoutput)
function
def percetagefind(achievement,target):
per=float(achievement)/float(target)
if per>=2.50:
return (" Incentive "+(float(achievement[x])*0.0225)
elif per>=2.00:
return (" Incentive "+(float(achievement[x])*0.002))
elif per>=1.50:
return (" Incentive "+(float(achievement[x])*0.0175))
elif per>=1.00:
return (" Incentive "+(float(achievement[x])*0.001))
elif per<=0.99:
return ("Target Not Achieved")
Upvotes: 1