Question

In: Computer Science

Suppose we have an input file that contains information about how many hours each employee of...

Suppose we have an input file that contains information about how many hours each employee of a company has worked. The file looks like the following (Employee's name, Hours): John 6.5 9.5 7.25 9 8.55 Oscar 12.5 13.5 14 16 18.75 Judith 7 7 7 ••• Construct a program that reads this file and calculates the total number of hours worked by each individual. Make sure that the program handles each specific exception that could occur.'

python

Solutions

Expert Solution

Short Summary:

  • Implemented the program in Python
  • PFB the source code and output

**************Please do upvote to appreciate our time. Thank you!******************

Source Code:

import sys

# Using readlines()
file1 = open('myfile.txt', 'r')
Lines = file1.readlines()
  
# Strips the newline character
try:
for line in Lines:
list1 = line.split()
list2 = list1[1:len(list1)]
count=0
for i in list2:
hour=float(i)
count=count+ hour
print("Name:",list1[0],", Hours worked:",count)
except ValueError:
print("Hours are not in number format")
except:
print("Unexpected error:", sys.exc_info()[0])

Code Screenshot:

Output:


**************Please do upvote to appreciate our time. Thank you!******************


Related Solutions

suppose that the reservoir contains 1.5L of 2.0M K2PO4. For how many hours can the reservoir...
suppose that the reservoir contains 1.5L of 2.0M K2PO4. For how many hours can the reservoir provide 20mM KOH at a flow rate of 1.0 ml/min if 75% consumption of K+ in the reservoir is feasible
The tbl_employee contains information about the employee and its department, and it contains the following fields...
The tbl_employee contains information about the employee and its department, and it contains the following fields (it is possible to also include other missing fields): employee_id, employee_gender ,employee_salary, employee_annual_sallary, department_name, department_location, department head. Make use of the database normalization skills learned to normalize a database to the third normalization form. Organize the columns and tables to reduce data redundancy and arrange attributes based on the relationships. Provide a screen shot of the database design before the normalization. Create a heading...
Suppose that we are using extendable hashing on a file that contains records with the following...
Suppose that we are using extendable hashing on a file that contains records with the following search-key values: (2, 3, 5, 7, 11, 17, 19, 23, 29, 31). Show the final extendable hash structure for this file if the hash function is h(x) = x mod 8 and buckets can hold three records. Recall that: 1. the bucket address table is indexed by the prefix of the binary representation of h(x). 2. Initially i = 0, i.e. the prefix consists...
Suppose we have the following information on the examination scores and weekly employment hours of eight...
Suppose we have the following information on the examination scores and weekly employment hours of eight students: Exam Score      Employment Hours       80                           10       80                           5       68                           15       95                           5       75                           21       60                           40       90                           0     100                           0 Assuming Exam Score is the dependent variable (Y) and Employment Hours is the independent variable (X), calculate the simple linear regression equation by hand. Using this, test to see whether the slope on X is...
2) The file ‘Energy’ contains the per capita energy consumption (in kilowatt-hours), for each of the...
2) The file ‘Energy’ contains the per capita energy consumption (in kilowatt-hours), for each of the 50 states and the District of Columbia during a recent year. a) Compute the mean, variance, and standard deviation for the population. b) What proportion of these states has per capita energy consumption within + or – 1 standard deviation of the mean, within + or – 2 standard deviations of the mean, and within + or – 3 standard deviations of the mean?...
The input file Each line of the input file will contain a sentence with words separated...
The input file Each line of the input file will contain a sentence with words separated by one space. Read a line from the listed below  and use a StringTokenizer to extract the words from the line. The input file . Mary had a little lamb whose fl33ce was white as sn0w And everywhere that @Mary went the 1amb was sure to go. Read the above that contains a paragraph of words. Put all the words in an array, put the...
Suppose we conduct a study with 100 participants to estimate how many hours students sleep and...
Suppose we conduct a study with 100 participants to estimate how many hours students sleep and find an average of 8 and a confidence interval that ranges from 5 to 11. What is the margin of error?
[In Python] Write a program that takes a .txt file as input. This .txt file contains...
[In Python] Write a program that takes a .txt file as input. This .txt file contains 10,000 points (i.e 10,000 lines) with three co-ordinates (x,y,z) each. From this input, use relevant libraries and compute the convex hull. Now, using all the points of the newly constructed convex hull, find the 50 points that are furthest away from each other, hence giving us an evenly distributed set of points.
C++ There is a file, called EmployeeInfo.txt, that contains information about company employees work for a...
C++ There is a file, called EmployeeInfo.txt, that contains information about company employees work for a week. You will write a program that reads the info from the file, and produces an output file called EmployeePay.txt with information about the employees pay amount for that week. Details: The input file is called EmployeeInfo.txt There are 4 lines of input Each line has the same form Last Name, first Name, hours worked, pay rate, tax percentage, extra deductions Example: John Doe...
Suppose we have a sequential ordered file of 200,000 records, where each record is 200 bytes....
Suppose we have a sequential ordered file of 200,000 records, where each record is 200 bytes. Assume blocksize = 2048 bytes (10 records per block), average seek time = 10 ms, average rotational delay = 8.3 ms, and block transfer time = 0.8 ms. Suppose we want to make X independent random record reads from the file. This could be done in two different approaches. read the entire file once and look for the X records of interest use a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT