Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON Exercise Save the file created in the Module 7 lab as product.py and create a new file named Add a __str()__ method to the

PYTHON

Exercise

Save the file created in the Module 7 lab as "product.py" and create a new file named

Add a __str()__ method to the product class so that a formatted output of the name, price, and initial DiscountPercent are returned along with the calculated values for DiscountAmount and DicountPrice. NOTE: Use a def __str__(self): method to format the output string as seen below. See pages 507-509 in the Gaddis book. Lines 36-37 of Program 10-9 (bankaccount2.py) shows an example in the book.

Create a new ".py" file using the naming convention for the deliverable mentioned at the top of the assignment

Use an import statement to gain access to your product class module file

Add a loop to the main() function and build as many objects as the user wants to by prompting the user for the 3 key attribute values necessary to create a product.

After creating an object it should be added to a list. The program should continue, and prompt the user for a choice to continue or not.

Once the loop has ended use a For In loop to print each object from within the list.

Sample input/output:

>>>Enter a product name: Stanley 13 Ounce Wood Hammer >>>Enter a price for this product: 12.99 >>>Enter a discount percentage: 5 >>>Enter another product? (Enter y/n): n

PRODUCTS: ================== Stanley 13 Ounce Wood Hammer Price: $12.99 Discount percent: 62% Discount amount: $8.05 Discount price: $4.9

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

1. Explain how new technologies are influencing training.

Answered: 1 week ago