I don't need the get_new_item and the color of the items but it breaks the code, how do I fix this?
WEIGHT_LIMIT = 100
COUNT_LIMIT = 4
wizard_inventory = []
def display_title():
print("The Wizard Inventory
print()
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()
def show(inventory):
print("Show inventory")
for i in inventory:
print(i[0], i[1], "(", i[2], ")lbs")
total = calculate_weight(inventory)
print("Total Weights is : ", total, "lbs")
print(" Weight limits of 100 lbs")
def calculate_weight(inventory):
total = 0
for i in inventory:
print(i[2])
total = total + float(i[2])
return total
def grab_item(inventory):
list = []
total = 0
if (len(inventory) < 4):
list.extend(get_new_item())
print(list)
total = calculate_weight(inventory)
total = total + float(list[2])
print(total)
if (total < 100):
inventory.append(list)
else:
print("weight exceeds limit of 100 lbs")
show(inventory)
# create a function which adds new items
def get_new_item():
New_Items = []
# store item in list
for i in range(3):
New_Items.append(input(f'Enter value at index {i}: '))
return New_Items
def edit_item(inventory):
index = int(input("Enter the index of the item to de edited: "))
if (index > len(inventory)):
print("Wrong index,Try Again!")
else:
Newname = input("Enter the new name for the item: ")
print("Before edit : ", inventory[index])
inventory[index][0] = Newname
print("After edit : ", inventory[index])
def drop_item(inventory):
index = int(input("Enter the index of the item to de deleted: "))
if (index > len(inventory)):
print("Wrong index,Try Again!")
else:
show(inventory)
inventory.pop(index)
show(inventory)
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: ")
print(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.\n")
print("Bye!")
if __name__ == "__main__":
main()
Step by stepSolved in 3 steps with 2 images
- Imagine that you own a flower store and you need to display a menu of all the item categories, items and prices you sell for your customers. Display the prices for each product and category. The flowers are {"Rose", "Carnation", "Tulips", "Sunflowers"}, the price in order are {1.15, 1.5, 2.5, 2.75} the second category is vase sizes, {"Small", "Medium", "Large", "XLarge"}, the prices in order are {1.25, 2.5, 3.75, 4.5}. The last category is add ons, {"Teddy Bear" , "note", "ballon", "choclates"}. The prices are in order {10.0, 2.5, 5.75, 8.75} The list of products and the list of prices should be stores in 2 separate arrays. Create a method "display" that accepts 2 arrays as parameters and displays the product and the prices in receipt form. Create another method "sum" that displays the total for each category.arrow_forwardNeed guidance on how to use Tkiner in visual studio. The tkiner program doesn't run, it shows as a syntax error. Code: from tkinter import* import tkinter.messagebox class Library: def __init_(self,root): self.root = root self.root.title("Library Inventory System") self.root.geometry("1350x750+0+0") BookId = StringVar() AuthorFullName=StringVar() PublicationYear=StringVar() BookTitle=StringVar() num_copies=StringVar() #===================Frames==========================# MainFrame = Frame(self.root) MainFrame.grid() TitleFrame = Frame(MainFrame, bd=2, padx=40, pady=8, bg="Cadet blue", relief=RIDGE) TitleFrame.pack(side=TOP) self.libTitle =Label(TitleFrame, font=('arial',46,'bold'),text="Library Inventory System") self.libTitle.grid(sticky=W) ButtonFrame…arrow_forwardJava codearrow_forward
- Make any necessary modifications to the RushJob class so that it can be sorted by job number. Modify the JobDemo3 application so the displayed orders have been sorted. Save the application as JobDemo4. An example of the program is shown below: Enter job number 22 Enter customer name Joe Enter description Powerwashing Enter estimated hours 4 Enter job number 6 Enter customer name Joey Enter description Painting Enter estimated hours 8 Enter job number 12 Enter customer name Joseph Enter description Carpet cleaning Enter estimated hours 5 Enter job number 9 Enter customer name Josefine Enter description Moving Enter estimated hours 12 Enter job number 21 Enter customer name Josefina Enter description Dog walking Enter estimated hours 2 Summary: RushJob 6 Joey Painting 8 hours @$45.00 per hour. Rush job adds 150 premium. Total price is $510.00 RushJob 9 Josefine Moving 12 hours @$45.00 per hour. Rush job adds 150 premium. Total price is $690.00 RushJob 12 Joseph Carpet cleaning 5 hours…arrow_forwardWhen the final score screen comes up I would like to implement an additional section on the UI that will show with the score. Depending on what score you received, is how much currency you will be rewarded. 2000-4000 = 5 currency 4000-7000 = 10 7000- 9999 = 15 It needs to be in C# This is what I have so before I got caught up. using System.Collections;using System.Collections.Generic;using UnityEngine;using System;using UnityEngine.UI; public class TierRewards : MonoBehaviour{private int finalScore; void Start(){finalScoreText.text = finalScore.ToString() + "Currency";CurrencyText.text = "Currency: " + Currency.ToString();} public void AddfinalScore(int Currency){finalScore += Currency;} public void Currency(int finalScore){ if (finalScore > 2000 && finalScore < 4000){Console.WriteLine("5");}else if (finalScore > 4000 && finalScore < 7000){Console.WriteLine("10");}else if (finalScore > 7000 && finalScore < 9999){Console.WriteLine("15");}}}arrow_forwardHere are what to display on your Pokémon's show page: The pokemon's name The image of the pokemon An unordered list of the Pokemon's types (eg. water, poison, etc). The pokemon's stats for HP, ATTACK, and DEFENSE. module.exports = [ { id: "001", name: "Bulbasaur", img: "http://img.pokemondb.net/artwork/bulbasaur.jpg", type: [ "Grass", "Poison" ], stats: { hp: "45", attack: "49", defense: "49", spattack: "65", spdefense: "65", speed: "45" }, ]; Routes Your app should use RESTful routes: Index GET /pokemon Show GET /pokemon/:id New GET /pokemon/new Edit GET /pokemon/:id/edit Create POST /pokemon Update PUT /pokemon/:id Destroy DELETE /pokemon/:idarrow_forward
- when coding a chess game, implement the following method: isInCheck(Side s): Returns true if the king of side s is attacked by any of the opponent’s pieces, i.e., if in the current board state, any of the opponents pieces can move to where the king is. Otherwise, it returns false. Note that this method is only used to warn the player when they are in check. You can use the GUI to test if this is working. public boolean isInCheck(Side side) { // TODO write this method return false; } public enum Side { BLACK, WHITE; public static Side negate(Side s) { return s == Side.BLACK ? Side.WHITE : Side.BLACK; } }arrow_forwardUser.java User is a class that represents a user in the music player application. Every User contains a library which stores all their Playlists. A User can create Playlists or add Playlists made by other users to their library. Additionally, they can also share Playlists with other Users. Each User has the following attributes: username - Represents the username of the user The name of a user should never be null library Represents the library of the User. A list that contains all the playlists the user has created or added. Every user's library will start with a playlist called "Liked" which stores the songs that the user has liked. This playlist should have a creation Date of 0. Save for the Liked playlist, a user's library should be sorted in order of recency. That is, a more recently created playlist should appear earlier than an older one. currentPlaying Represents the song the user is currently listening to. -If it is null, then the user is not listening to any song. User should…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY