Question: (Python) This program will read the data located in a text file called invoice.txt. Each line in the file contains an item followed by the
(Python) This program will read the data located in a text file called invoice.txt. Each line in the file contains an item followed by the delimiting character # followed by the item price. The program will then display the items and their prices as well as the cumulative price totals and the total number of items in the file. A sample run using the data in the file invoice.txt is shown below. To gain full credit for this lab, the output must be formatted as shown below
Sample run This program will read each line in the file invoice.txt and print a a table indicating the item and its cost. When the file is exhausted, it will print the cumulative sum of all of the costs and the total number of items. Item Cost hammer $ 9.95 saw $20.15 shovel $35.40 Total cost $65.50 Number of tools 3
*** invoice.txt
hammer#9.95saw#20.15shovel#35.40
# output descriptive messages print('This program will read each line in the file invoice.txt and print a ' + 'a table indicating the item and it\'s cost. When the file is exhausted, ' + 'it will print the cumulative sum of all of the costs and the total ' + 'number of items. ')
# display header line for items list print('{0: <10}'.format('Item'), '{0: >17}'.format('Cost'), sep = '' )
# add your remaining code below
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
