asked 841 views
0 votes
In this exercise, you'll create Product _Viewer.py and Objects.py. When you enter the product number, it should print the product data to the console.In IDLE, write the following code and name your file using product_viewer.py write the following code and name your file using objects.py le display screen should look like the following scree The Product Viewer program PRODUCTS 1. Stanley 13 Ounce Wood Hammer 2. The Big Short by Michael Lewis 3. The Holy Grail - DVD (1975) Enter product number: 1 PRODUCT DATA Name: Stanley 13 Ounce Wood Hammer Discount price: 4.94 View another product? (y/n):y Enter product number: 2 PRODUCT DATA Name: The Big Short Author: Michael Lewis Discount price: 10.53 View another product? (y/n):y Enter product number: 3 PRODUCT DATA Name: The Holy Grail - DVD Year: 1975 Discount price: 4.80 View another product? (y/n):n Bye: >>> should look like the following screen. Enhance The Product Viewer Program by Naja El-Khoury The Product Viewer program PRODUCTS 1. Stanley 13 Ounce Wood Hammer 2. The Big Short by Michael Lewis 3. The Holy Grail - DVD (1975) Enter product number: 1 PRODUCT DATA Name: Stanley 13 Ounce Wood Hammer Discount price: 4.94 View another product? (y/n):y Enter product number: 4 Please type a number between 1 and 3 View another product? (y/n):y Enter product number: 2 PRODUCT DATA Name: The Big Short Author: Michae1 Lewis Discount price: 10.53 View another product? (y/n):n Bye! >>1

In IDLE, open your project 9 "product_viewer.py".
Enhance your project so if the user enter any product number greater than 3, you display a message ("Please type a number between 1 and 3").
Review the code and run "enhance_product_viewer.py" to make sure it works correctly.
Add your name to the top of the program "enhance_product_viewer.py".
Save your "enhance_product_viewer.py" run your program, test your program your console display screen should look like the following screen.

1 Answer

3 votes

Final answer:

To enhance the Product Viewer program, you can add a condition that checks if the user enters a product number greater than 3. If true, display a message to enter a number between 1 and 3.

Step-by-step explanation:

To enhance the Product Viewer program, you can add a condition that checks if the user enters a product number greater than 3. If this condition is true, you can display a message to the user saying, 'Please type a number between 1 and 3.' This can be implemented by adding an 'if' statement after the user enters the product number, and using the 'print' function to display the message.

Here is an example of how you can modify the code:

if product_number > 3:
print('Please type a number between 1 and 3')

By making this modification, the program will prompt the user to enter a valid product number within the range of 1 to 3, ensuring that they do not enter an invalid value.

answered
User Morgano
by
8.6k points