Beruflich Dokumente
Kultur Dokumente
Write code in python to read payroll data of hourly workers from a file, store the data into a list of object
(see course notes of student roster as an example) and print pay information to both the console and an
output file.
A sample of data found in payroll.txt is below: (please create your own data)
4123 Adam Carlson 12 15.0 8.0 1 3
5456 Barney Craig 22 4 11.6 5 12
7189 Catlyn Davis 10 8 7.5 2
2012 David Ellis 9 4.5 1.5 1
1345 Emma Franklin 28 40
1678 Dan George 15 6.5 2.0 3.5 4 5.0
1901 Phil Hall 10 9 8.5 7 6.5 5 1.5
8234 James Henry 17 0 0 0 1 0 0 4
2567 Lisa Lincoln 55 5.0 3.0 2.5 3
3890 Mike Watson 21 12.5 16.5 11
The data is organized as columns consisting of the following information about each
employee: Employee ID, Employee First Name, Employee Last Name, hourly wage, a list
of daily hours worked by the employee.
For example, the first row: 4123 Adam Carlson 12 15.0 8.0 1 3
This row has the following entries:
Hourly wage: 12
One way to read this data from the file is to read it one line at a time. Where each
line represent a single employee information. For example
If the name of your file object is f, you can loop through it one line at a time:
For line in f:
Then you can split the line using the split function.
e.g.,
columns = line.split()
id = columns[0] # "123"
name = columns[1]+' '+columns[2] # "Suzy"
wage = float(columns[3])
days = columns[4:]
What to submit:
Create a word document named your Full Name + hw3, if student name is Lisa Lincoln, the document
name should be LisaLincolnHw1.docx
Copy and paste your own code and a screen capture of sample I/O for each exercise.