Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python, explanations help. 4. Write a function payroll0 that takes two string parameters, the first of which represents the name of an input file

image text in transcribed

In python, explanations help.

4. Write a function payroll0 that takes two string parameters, the first of which represents the name of an input file and the second of which represents the name of an output file. The input file contains lines with the following format: hours pay_rate where hours is an integer representing a number of hours worked and pay_rate is a floating point value representing the pay rate per hour. There will be some whitespace between the two values, although you may not make any assumptions about how much or what type. The function reads the input file line by line, computing the total pay (i.e. the product of the hours times the pay ratewe are not assuming overtime is computed for any of the values) and writing each amount to a newline in the output file. If the file is empty, the function should not write any numbers to the output file. Note that the strings read from the file will need to be evaluated before you can use them for computations. If the output file exists, it should be cleared as it is opened. The following shows what the function would return when called on several sample files found in the zip file containing the assignment template. Don't forget to close both the input and output files. Assignment 4-CSC 241-801 Python 3.62 Shell Eile Edit Shell Debug Options Window Help >>>payroll'payl.txtout1.txt inf-open('outi.txt'' >>for line in inf: print (line, end 157.5 1006.0 116.25 245.0 >>>int.close ) >>>payrolll'pay2.txt', 'out2.txt >>>inf -open('out2.ext'' >>for line in inf: print (line, end 878.75 578.0 367.0 310.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Database And Knowledge Base Systems

Authors: S Krishna

1st Edition

9810206208, 978-9810206208

More Books

Students also viewed these Databases questions