QuestionQuestion

Write a console program that prompts for the name of, and then reads, a file of data about the number of hours worked by several employees. Each line begins with the employee's ID number, followed by their name, then a sequence of numbers representing how many hours they worked each day. For example:
123 Amy 12.5 8.5 7.25 3.25
456 Miles 4.0 11.6 6.5 12.2 2.7 802 Jessie 1.5
647 Vilde 8.0 3.5 6.5

Your program should prompt for the file name to read, then read its data and compute the total and average hours worked by each person. Use the following format:
Input file? hours.txthours.txt
Amy (ID#123) worked 31.5 hours (7.9/day)
Miles (ID#456) worked 37.0 hours (7.4/day)
Jessie (ID#802) worked 1.5 hours (1.5/day)
Vilde (ID#647) worked 18.0 hours (6.0/day)

You may assume that the user types the name of a file that exists and is readable, and that the data is in the valid format shown above. Use the printf function to round numbers as necessary.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

# main.py

def main(file_name):

    file_handler = open(file_name)

    lines = file_handler.readlines()

    for line in lines:

       data = line.strip().split()

       worker_id = data[0]
       worker_name = data[1]
       hours = data[2:]...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$8.00 $4.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats