Question
Python Lab Assignment Directions: Add the necessary code to the source file Scan.py. This program will read the data located in a text file called
Python Lab Assignment
Directions:
Add the necessary code to the source file Scan.py. 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
# * Statement: Echos the contents of the file invoice.txt and sums prices and # * count of items # * Specifications: # * Input - string describing a tool in the file invoice.txt # * - price of the tool in the file invoice.txt # * Output - Message indicating the item and the cost # * - The sum of all costs and the number of items in the file invoice.txt # ************************************************************************/
# 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
Code needs to display these results.
invoice.txt file includes this text: hammer#9.95saw#20.15shovel#35.40
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started