tauk

Total and Average worker hours using for loop and input

Jun 16th, 2020
1,134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. #intialize total_hours to 0
  2. total_hours = 0
  3.  
  4. #use for loop to enter works hours for 10 workers
  5. for i in range(10):
  6.     worker_hours = float(input("Enter hours for worker:"))
  7.     # add the worker_hours to the total_hours
  8.     total_hours = total_hours + worker_hours
  9.  
  10. # calculate the average worker hours
  11. average_hours = total_hours / 10
  12.  
  13. # output the total hours and the average hours
  14. print("Total Worker Hours: ", total_hours)
  15. print("Average hours:", average_hours)
Advertisement
Add Comment
Please, Sign In to add comment