create a python script using the requirements and explain how it functions, please. I have added my starter code to work from as well as my desired outcome in the examples below. I attached my stater code in a screenshot as it was too long to include in my question for this exercise.
create a python script using the requirements and explain how it functions, please. I have added my starter code to work from as well as my desired outcome in the examples below. I attached my stater code in a screenshot as it was too long to include in my question for this exercise.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Topic Video
Question
create a python script using the requirements and explain how it functions, please. I have added my starter code to work from as well as my desired outcome in the examples below. I attached my stater code in a screenshot as it was too long to include in my question for this exercise.
you will complete a program that keeps track of the inventory of items a wizard is carrying. Your program will allow the user to show/add/remove/modify the items the wizard is carrying.
You are given a partially written code for this program;
your job is to write 4 functions that implement response to user commands. Read and understand the existing code –it has implemented the functions that handle printing welcome messages and the rules, and also the main function that handles the command loop. You are supposed to implement four functions -show, grab_item, drop_item, edit_item-that accept two lists: a list containing the names of the items and the other containing the weights of the items. The main function initializes the names list with 3 items “wooden staff”, “wizard hat”, “cloth shoes” and the weights list with weights of those items as 30.0, 1.5, 5.3 lbs respectively.
Here's what each function that you are implementing is supposed to do:
1.show: Lists the items that the wizard is currently carrying along with the index for each item and the weight of that item. See sample runs below. As shown in the sample this function also prints the total weight of the items along with the max weight limit of 100 lbs.Hint: You can use the sum function in Python to calculate the sum of weights. E.g. sum(weights) will return the sum of all the items in the weights list.
2.grab_item: Add a new itemwhile enforcing the following policy: There is a limit of 4 on the number of items the wizard can carryand a limit of 100 lbs on the total weightthe wizard can carry. So specifically, if the wizard is already carrying 4 items, print message that “You can't carry anymore items. Drop something first.”And return out of the function. Otherwise prompt the user for the name and the weight of the new item. Next check whether with the addition of the new item,the total weight will exceed the limit of 100 lbs. If so, print a message saying the weight limit will be exceeded, so cannot add the new item and return it out of the function. Otherwise, add the new name and weight to the two lists. See Sample runs below. Hint: You can use the sum function in Python to calculate the sum of weights. E.g. sum(weights) will return the sum of all the items in the weights list.
3.edit_item: Allow the user to update (only) the name of one of the items. Prompt the user for the index of the item to be edited. Validate that the index is between 1 and the current count of items.If invalid, print a message to that effect and exit. Otherwise prompt the user for the new name and update the name of the item. Print that the item was updated successfully. See Sample runs below.
4.drop_item: Prompt the user for the index of the item to be dropped. Validate that the index is between 1 and the current count of items. Remove the item from both lists. Print that the item was removed successfully. See Sample runs below.Read the description above and the sample runs shown below closely to understand what each command does. Add useful comments throughout the code.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education