16.8k views
0 votes
Imagine that you are helping to build a store management system for a fast food restaurant. Given the following lists, write a program that asks the user for a product name. Next, find out if the restaurant sells that item and report the status to the user. Allow the user to continue to inquire about product names until they elect to quit the program.

User Praneybehl
by
4.2k points

1 Answer

3 votes

Answer:

The program in python is as follows:

def checkstatus(food,foodlists):

if food in foodlists:

return "Available"

else:

return "Not Available"

foodlists = ["Burger","Spaghetti","Potato","Lasagna","Chicken"]

for i in range(len(foodlists)):

foodlists[i] = foodlists[i]. lower()

food = input("Food (Q to quit): ").lower()

while food != "q":

print("Status: ",checkstatus(food,foodlists))

food = input("Food (Q to quit): ").lower()

Step-by-step explanation:

The program uses function.

The function is defines here. It accepts as input, a food item and a food list

def checkstatus(food,foodlists):

This check if the food is in the food lists

if food in foodlists:

Returns available, if true

return "Available"

Returns Not available, if otherwise

else:

return "Not Available"

The main begins here.

The food list is not given in the question. So, I assumed the following list

foodlists = ["Burger","Spaghetti","Potato","Lasagna","Chicken"]

This converts all items of the food list to lowercase

for i in range(len(foodlists)):

foodlists[i] = foodlists[i]. lower()

Prompt the user for food. When user inputs Q or q, the program exits

food = input("Food (Q to quit): ").lower()

This is repeated until the user quits

while food != "q":

Check and print the status of the food

print("Status: ",checkstatus(food,foodlists))

Prompt the user for another food

food = input("Food (Q to quit): ").lower()

User Jigar Pancholi
by
3.1k points