Python AI Program Design
Assignment Nine
Student Scope: Artificial Intelligence major, Intelligent Science and Technology major, Class of 2025
Assignment Submission Deadline: November 19, 2025, 18:00
1. Assignment Content
Product Price Management System
Create a product price management system that uses a dictionary to store product information and implements functions for adding, querying, modifying, deleting, and displaying products.
Program Requirements:
- 1. Create an empty dictionary to store product information (product name as key, price as value)
- 2. Add at least 5 products and their prices to the dictionary
- 3. Implement the following functional functions:
- •
<span class="language-python">add_product(products, name, price)</span>: Add new product and price - •
<span class="language-python">query_price(products, name)</span>: Query product price (use get() method for safe access) - •
<span class="language-python">update_price(products, name, new_price)</span>: Update product price - •
<span class="language-python">remove_product(products, name)</span>: Remove discontinued product - •
<span class="language-python">show_all_products(products)</span>: Display all products and prices
Output Example:
=== Product Price Management System ===
Initial product list:
Apple: 5.50 yuan
Banana: 3.20 yuan
Orange: 6.80 yuan
Grape: 12.00 yuan
Watermelon: 8.50 yuan
--- Add New Product ---
Add product: Strawberry, Price: 15.00 yuan
Add successful
--- Query Product Price ---
Query product: Apple
Price: 5.50 yuan
Query product: Mango
This product does not exist
--- Update Product Price ---
Update product: Banana, New Price: 3.50 yuan
Update successful
--- Remove Discontinued Product ---
Remove product: Watermelon
Remove successful
--- Current All Products ---
Apple: 5.50 yuan
Banana: 3.50 yuan
Orange: 6.80 yuan
Grape: 12.00 yuan
Strawberry: 15.00 yuan
Total number of products: 5 types
2. Submit Assignment
Submit the following content to the teaching assistant’s email in the course group:
Submission Format Requirements:
- • Email Subject: [Assignment Nine] Name-Student ID
- • File Naming: Assignment_Nine_Name_StudentID.docx
- • Screenshot Requirements: Clear and visible, resolution not lower than 1080p
Submission Content:
- • Source code (.py) file
- • Running result screenshot, must include:
- • Complete test results (including all function tests)
- • At least 3 query operations (including both existing and non-existing products)
- • At least 2 price updates and 1 deletion operation
- • Display the final complete product list