Question
1. Considering the code provided answer the following questions a. What are the names of the functions and what does each one do? b. Which
1. Considering the code provided answer the following questions
a. What are the names of the functions and what does each one do?
b. Which functions are Value-Returning Functions?
c. Which functions are Non-Value-Returning Functions?
d. Are there any global variables? If so, mention them
e. Are there any local variables? If so, mention them.
f. Write the statement to invoke each of the functions and what is the output when the function is called (prints, values, etc.)
Ex: See the total sales of the day
Statement: see_sales()
Output: Total Sales: 0
i. See the menu
ii. See Inventory
iii. Add an item
iv. Purchase an item
v. See total amount of money in inventory
sales =0 inventory = [['Item! ' , 2.20], ['1tern2 ' , 4.36], ['1tem3-12.32]] def show menu ): print ('1) Purchase n' '2) See inventory ' '3) Add Item ' '4) See sales ') def see_inventory): for idx in inventory: print (idx[0]+""+str (idx[1])) def add item (item, price): inventory.append ([item,price]) def purchase ): for idx in range (len (inventory) print (str (idx)) tinventory[idx] [0]) index = int (input ('Select a number: if Index >=0: ')) item = inventory [index] del inventory[index] return item[1] #Item price else: print ('Item not found') return 0 def amount_in_inventory): acum = 0 for idx in inventory: acum+=idx [ 1 ] return acum def see sales (): print ('Total Sales: '+sales)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started