Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!