I am in a python coding class. I was asked to do a FOR loop project where the project reads the number or the name of an employee and pops the name with the pay of the employee. The range is 5. These are the instructions:
With this programming project I want you to use a FOR loop to incorporate into your Employee Pay program and now rather than run through a single employee, calculate the pay and end it should loop through a specific number of employees. As in if your company happens to have 5 employees then it should loop 5 times for each of the 5 different employees and THEN end.
You will have one (this one) where you have 5, 10 a certain specific number of employees – 10 for example – (the 2nd Iteration – the next program- will be where you may have an “unknown” number and you must quit at a prompt of for example when the employee number entered is “999” – This loop will be a FOR loop where a basic example might look something like
This is what I have code so far. Please send help, I can not get my code to work and I really don’t see how my preceptor wants me to use these FOR loops, I can see it using the while loops but not the For. Thank you!
num_employee = input(‘Enter number of employees: n’)
employee_name = input(‘Enter employee name: n’)
name_list = []
hourly_rate = float(input(‘Enter hourly rate: n’))
hours_worked = float(input(‘Enter hours worked: n’))
over_time = hours_worked – 40
Salary = 0
if hours_worked > 40:
salary = (over_time * hourly_rate * 1.5) + (40 * hourly_rate)
elif hours_worked <= 40:
salary = hours_worked * hourly_rate
for i in range(num_employee):
name_list.append(input())
print('According to payroll,', name_list, 'worked', hours_worked, 'this week. At a rate of', '$',hourly_rate, ' per hour, the total pay is $',salary, 'for this pay period.')
Francisco Javier is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.