Knowee
Questions
Features
Study Tools

For each day it will ask the user for number of hours that employee worked and use the add_hours function to add this to the list of hours_worked in employee class.

Question

For each day it will ask the user for number of hours that employee worked and use the add_hours function to add this to the list of hours_worked in employee class.

🧐 Not the exact question you are looking for?Go ask a question

Solution

It seems like you're asking for a step-by-step guide on how to implement a feature in a program that asks the user for the number of hours an employee worked each day and adds this to a list of hours worked in an employee class. Here's a simple way to do it in Python:

  1. First, define the Employee class with an empty list for hours_worked:
class Employee:
    def __init__(self):
        self.hours_worked = []
  1. Next, define the add_hours function. This function should take the number of hours worked as an argument and append it to the hours_worked list:
    def add_hours(self, hours):
        self.hours_worked.append(hours)
  1. Now, outside of the class, create a loop that asks the user for the number of hours worked each day. You can use the input function to get user input:
employee = Employee()
for i in range(7):  # Assuming a 7-day work week
    hours = int(input("Enter the number of hours worked today: "))
    employee.add_hours(hours)
  1. At this point, the hours_worked list in the employee object should contain the number of hours worked for each day. You can print this list to verify:
print(employee.hours_worked)

This is a very basic implementation and might need to be adjusted based on the specifics of your program.

This problem has been solved

Similar Questions

Ask user for employee name and pay rate.Create the employee object.Ask user for the number of days the employee worked.For each day it will ask the user for number of hours that employee worked and use the add_hours function to add this to the list of hours_worked in employee class.It will display the employee data as follows (use f string to format the output):Employee Name: Joe DoePay Rate: $ 25.75 per hourTotal number of hours worked: 39.45Total Salary: $ 1015.84

An employee will have a name, pay_rate, and list of hours_worked.Employee class must have following methods:Constructor – takes name and pay_rate. It will also creat an empty list of hours_worked.add_hours – takes hours as a parameter and add it to the hours_worked list.salary – calculates the salary for the employe (pay_rate x total hours worked).Write a main function that will:Ask user for employee name and pay rate.Create the employee object.Ask user for the number of days the employee worked.For each day it will ask the user for number of hours that employee worked and use the add_hours function to add this to the list of hours_worked in employee class.It will display the employee data as follows (use f string to format the output):Employee Name: Joe DoePay Rate: $ 25.75 per hourTotal number of hours worked: 39.45Total Salary: $ 1015.84

_________ is the number of workdays or work hours required to complete a task.

The numbers of hours worked (per week) by 400 statistics students are shown below.  Number of hoursFrequency   0 -   9  20 10 - 19  80 20 - 29200 30 - 39100

Employee Schedules: Timothy, Kara, Samantha, and Mike are all employees in the same organisation. The offices are open 24hours/7days a week.Timothy works for 8 hours on Monday, Tuesday, and Wednesday. Kara works for 5 hours on Tuesday and Wednesday, and 10 hours on Friday. Mike works 32 hours total between Thursday and Sunday. And Samantha works between 1pm and 6pm on Monday, 4am and 1pm on Friday, and from 11pm on Saturday to 6am on Sunday.What is the total number of hours worked in a week by all four employees? 94 97 122 114 Not enough information

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.