Can someone help me write code to remember the names and total amount of hours done by an employee so that I can figure out who is the winner. In order to be the winner, you need at least 20 hours. If multiple people have the highest amount then those people are the winner.
i = 1
totalHoursAllEmployees = 0
totalActivitiesAllEmployees = 0
mostAmountHours = 0
leastAmountHours = -1
while i <= 3:
nbrAct = 0
empHours = 0
name = input("\nEnter your name: ")
j = 1
while j <= 6:
hoursPerAct = int(input("How many hours did you participate in activity {} {}?: ".format(j,name)))
j += 1
empHours += hoursPerAct
if hoursPerAct > 0:
nbrAct += 1
totalHoursAllEmployees += empHours
totalActivitiesAllEmployees += nbrAct
if empHours > mostAmountHours:
mostAmountHours = empHours
elif empHours < mostAmountHours and empHours > leastAmountHours and leastAmountHours != -1:
pass
else:
leastAmountHours = empHours
#Remember the name and amount of hours done in total by each employee
print("\nName of the employee:",name)
print("Total amount of hourd done by",name,":",empHours)
print("Number of activities done by",name,":",nbrAct)
i += 1
print("\nTotal amount of hours done by all 3 employees:",totalHoursAllEmployees)
print("Total amount of activities participated in by all 3 employees:",totalActivitiesAllEmployees)
print("Least amount of hours done by an employee:",leastAmountHours)
print("Most amount of hours done by an employee:",mostAmountHours)
print("Average amount of hours done by all 3 employees:", totalHoursAllEmployees/3)
#print out name of the winners
Aucun commentaire:
Enregistrer un commentaire