Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python project This application is for you, the shopper in mind. Putting together an itemized shopping list that contains the items you need , the

Python project

This application is for you, the shopper in mind. Putting together an itemized shopping list that contains the items you need, the items you want, and the anticipated cost, this program will generate a total price. This way you can decide if your shopping budget fits the bill.

Example list:

Price List

Binder paper: 2.29

Mop: 7.50

Scouring pads: 5

Your application program will create and write a new list to an output file in which the need and wish items are indistinguishable (i.e. input file labels have been removed). Your program will format this file so that items are left-aligned and the prices are right-aligned. The last line has the total of the prices.

The Program Spec

Obtain the input and output filenames from the user. Use the supplied test file, lab4.txt, for your submission run.

This program will read a file whose lines contain items and prices, in the format:

Item name 1: price 1

Item name 2: price 2

Note that each item name is terminated with a colon.

The program will write a file in which the items are left-aligned and the prices are right-aligned. The last line has the total of the prices. Floating point numbers will be formatted to two decimal places.

Your program will prompt the user for the name of the text file that contains your itemized shopping list. This itemized list will contain the item, followed by a colon, followed by a price.

Example:

Binder paper: 2.29

Hint: Make sure that there is a colon (:) in the lines that get copied into the outfile list.

Note: The test file does contain lines without a colon your program needs to recognize this and skip these lines (i.e. the new file should not contain these lines).

To get you started, an itemized list, lab4.txt, is attached for you to use for your lab assignment. Use this text file for your lab submission test verification run.

---------------------------------------------------------

lab4.txt is below:

Price List - Definitely Need

Apples: .57

Binder paper: 2.29

Cheese: 1.59

Mop: 7.50

Scouring pads: 5

Shampoo: 2.54

Wish List

Conditioner: 2.79

Ice Cream: 5.89

----------------------------------------------------------------------------

Your program will prompt the user for the input (i.e. lab4.txt) and output (i.e. yournameLab4out.txt) filenames.

Deliverables (2 files expected):

yournameLab4.py Your source code solution and a copy of the program run (i.e. the console output). Be sure to comment out your run (i.e. console output display) so that your .py file will still run in the grader test bed.

yournameLab4out.txt Your output file (i.e. this is the file generated by your program run).

Input Error Checking: Use a try-except construct to catch an invalid input file.

Here are some other tips and requirements:

1. Use the input file lab4.txt provided for one of your 2 required test runs.

2. Name the output file yournameLab4out.txt (i.e. Ann San Mateos output file would be sanMateoLab4out.txt).

3. Submit 2 files: the output file text and your Python source file. Be sure that your source file includes a commented copy of the script run output to the console.

4. Make sure to skip input lines that do not contain a colon.

5. Format output file as per the specification.

6. Provide a try-except construct.

7. Use a for loop to run a minimum of 2 test cases: test case 1: demonstrates try-except; test case 2: successful test run.

8. Here is a sample run (remember use the lab4.txt file provided with this assignment specification).

---------------------------------------

input file:

Price List

Binder paper: 2.29

Mop: 7.50

Scouring pads: 5

------------------------------------------------

output file:

Binder paper 2.29

Mop 7.50

Scouring pads 5.00

Total: 14.79

-----------------------------------------

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

MFDBS 91 3rd Symposium On Mathematical Fundamentals Of Database And Knowledge Base Systems Rostock Germany May 6 9 1991

Authors: Bernhard Thalheim ,Janos Demetrovics ,Hans-Detlef Gerhardt

1991st Edition

3540540091, 978-3540540090

More Books

Students also viewed these Databases questions

Question

How did you feel about taking piano lessons as a child? (general)

Answered: 1 week ago