Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create Program that keeps track of the inventory of items a wizard is carrying. The program allows the user to show/add/remove the items the wizard

Create Program that keeps track of the inventory of items a wizard is carrying. The program allows the user to show/add/remove the items the wizard is carrying.  WEIGHT_LIMIT = 100 COUNT_LIMIT = 4 def display_title(): print("The Wizard Inventory program") print() '''Function prompt the user for name, color and weight of the new item and return them as a list of the form: [name, color, weight] Make sure the weight parameter is > 0 ''' def get_new_item(): pass #Implement this '''Function to calculate the total weight of all the items in the inventory which is a list of lists representing items in the wizard's bag ''' def calculate_weight(inventory): pass #Implement this def display_menu(): print("COMMAND MENU") print("show - Show all items") print("grab - Grab an item") print("edit - Edit an item") print("drop - Drop an item") print("exit - Exit program") print() '''Function to show the list of items in the inventory in the form: 1. Brown Wooden staff ( 30.0 lbs ) 2. Black Wizard hat ( 1.5 lbs ) etc At the end print the current total weight of the items and the weight limit of 100 lbs. ''' def show(inventory): pass #Implement this '''Function to add a new item to the inventory. If the wizard is carrying less than 4 items, prompts the user for the name, color and weight of the new item. If adding the new item doesnt exceed the weight limit of 100 lbs, adds that item at the end of the list. Prints that the new item was added successfully. There is a limit of 4 on the number of items the wizard can carry. So if he/she is already carrying 4 items, prints message that "You can't carry anymore items. Drop something first." ''' def grab_item(inventory): pass #Implement this '''Function to edit the name of an existing item. Prompts the user for the index of the item to be edited. Validates the index. Then prompts the user for the new name for that item. Updates the name of the item. Prints that the item was updated successfully ''' def edit_item(inventory): pass #Implement this '''Function to drop an item. Prompts the user for the index of the item to be dropped. Validates the index. Removes the item. Prints that the item was removed successfully. ''' def drop_item(inventory): pass #Implement this def main(): display_title() display_menu() # start with these 3 items wizard_inventory = [["wooden staff", "Brown", 30.0], ["wizard hat", "Black", 1.5], ["cloth shoes", "Blue", 5.3]] while True: command = input("Command: ") if command == "show": show(wizard_inventory) elif command == "grab": grab_item(wizard_inventory) elif command == "edit": edit_item(wizard_inventory) elif command == "drop": drop_item(wizard_inventory) elif command == "exit": break else: print("Not a valid command. Please try again. ") print("Bye!") if __name__ == "__main__": main()

Expected Output:

image text in transcribedimage text in transcribed

- *Python 3.8.1 Shell* Eile Edit Shell Debug Options Window Help The Wizard Inventory program Ln: 188 Col: 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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions