Question

In: Computer Science

Please write in Python 3.7.4 or Higher. The Payroll Department keeps a list of employee information...

Please write in Python 3.7.4 or Higher.

The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage>

Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period.

  • The report should be in tabular format with the appropriate header.
  • Each line should contain:
    • An employee’s name
    • The hours worked
    • The wages paid for that period.

An example of the program input and output is shown below:

Enter the file name: data.txt

Name            Hours      Total Pay
Lambert            34         357.00
Osborne            22         137.50
Giacometti          5         503.50

Solutions

Expert Solution

Given below is the code for the question. Ensure to indent as shown in image.
Please do rate the answer if it helped. Thank you

filename = input('Enter input filename: ')
try:
   f = open(filename, 'r')
except:
   print('Error opening file ' , filename)
   exit()

print('{:<12s} {:>10s} {:>10s}'.format('Name', 'Hours', 'Total Pay'))
for line in f.readlines():
   lname, hours, wage = line.split()
   hours = int(hours)
   wage = float(wage)
   total = hours * wage
   print('{:<12s} {:>10d} {:>10.2f}'.format(lname, hours, total))

f.close()


Related Solutions

in python language The Payroll Department keeps a list of employee information for each pay period...
in python language The Payroll Department keeps a list of employee information for each pay period . The format of each line of the file is the following: <lastname> < hours worked> < Income> Write a program that inputs from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain an employee’s name, the hours...
The Payroll Department keeps a list of employee information for each pay period in a text...
The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain: An employee’s name The hours worked The wages paid...
in python please Q1) Create a Singly link list and write Python Programs for the following...
in python please Q1) Create a Singly link list and write Python Programs for the following tasks: a. Delete the first node/item from the beginning of the link list b. Insert a node/item at the end of the link list c. Delete a node/item from a specific position in the link list Q2) Create a Singly link list and write a Python Program for the following tasks: a. Search a specific item in the linked list and return true if...
Python 3.7.4 (Introductory Level) You want to know your grade in Computer Science: Write a program...
Python 3.7.4 (Introductory Level) You want to know your grade in Computer Science: Write a program that continuously takes grades between 0 and 100 to standard input until you input "stop", at which point it should print your average to standard output.
Write a program IN PYTHON of the JUPYTER NOOTBOOK that keeps getting a set of numbers...
Write a program IN PYTHON of the JUPYTER NOOTBOOK that keeps getting a set of numbers from user until the user enters "done". Then shows the count, total, and average of the entered numbers. This should the answer when finished Enter a number: 55 Enter a number: 90 Enter a number: 12 Enter a number: done You entered 3 numbers, total is 157, average is 52.33333
Python program please no def, main, functions Given a list of negative integers, write a Python...
Python program please no def, main, functions Given a list of negative integers, write a Python program to display each integer in the list that is evenly divisible by either 5 or 7. Also, print how many of those integers were found. Sample input/output: Enter a negative integer (0 or positive to end): 5 Number of integers evenly divisible by either 5 or 7: 0 Sample input/output: Enter a negative integer (0 or positive to end): -5 -5 is evenly...
List department name, employee id, and employee name for all employees in department name order. Repeat...
List department name, employee id, and employee name for all employees in department name order. Repeat for department #10 only. List the course ID, course name, section, instructor name, day, time, and room for all course sections. List the course ID, course name, section, student ID, and student name for CRN 1003. Display the list in ascending order of student last and first names. DROP TABLE registration; DROP TABLE sections; DROP TABLE courses; DROP TABLE students; DROP TABLE instructors; CREATE...
Using Python 3, Write a class called GolfScore that keeps track of the score for a...
Using Python 3, Write a class called GolfScore that keeps track of the score for a person playing a round of golf. We will limit the round to 9 holes, just to make testing easier. As a reminder, the holes on the golf course are numbered 1 – 9. Create a class level variable named NUM_OF_HOLES set to 9. Methods to be written: The constructor – sets the score for all holes to -1 addScore (hole, score) – this method...
Python: Write a program that keeps track of a game score and declares the winner when...
Python: Write a program that keeps track of a game score and declares the winner when the game is over. A game is over when either one player scores 10 or more points with at least 2 more points than the opponent. A game is also over when one player scores 7 points and the opponent scores none. The program should begin by asking the names of the two players. Then, it should keep asking who won the point till...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the functions defined below. You are expected to re-use these functions in implementing other functions in the file. Include a triple-quoted string at the bottom displaying your output. Here is the starter outline for the homework: a. def count_character(text, char): """ Count the number of times a character occurs in some text. Do not use the count() method. """ return 0 b. def count_sentences(text): """...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT