Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lists. Read the problem and answer the following five questions about it . Three friends Amanda, Derek, and Maya decided to have a picnic. They

Lists. Read the problem and answer the following five questions about it.
Three friends Amanda, Derek, and Maya decided to have a picnic. They created a grocery list with nine items and divided the list into three parts (parts can be not equal). Each of them should buy at least two products. Derek and Maya bought the correct products, but Amanda lost her shopping list and bought four products she remembered to be on the grocery list.
However, she only bought one of the products she was supposed to buy and three other products, which were not on her list. One of the products in the grocery list was not bought by anyone.
The following code shows what happened with the shopping list and shopping cart of Amanda. You need to find i, j, and k to run it correctly.
HINTS: First, find what products Amanda bought by tracing amanda_shopcart in the code. What the first product did she buy? Did she buy apples? Then, check what she should have bought: she bought only one correct product and one product was not bought by anyone; however, Maya and Derek bought everything what was on their lists!
# PROGRAM CODE
grocery_list =["apples", "bananas", "strawberry", "watermelon", "sausages", "bread", "cheese", "chips", "salsa"]
i =?
j =?
k =?
maya_shoplist = grocery_list[0:i]
amanda_shoplist = grocery_list[i:j]
derek_shoplist = grocery_list[j:]
print(amanda_shoplist) # what she should have bought
amanda_shopcart =[]
for i in range (1,k):
amanda_shopcart.append(grocery_list[i])
#print(amanda_shopcart)
if "apples" in amanda_shopcart:
amanda_shopcart.remove("apples")
else:
amanda_shopcart.insert(0,"apples")
print(amanda_shopcart) # what she actually bought
What product was missing from the picnic because it was not bought by anyone?
Group of answer choices
bananas
sausages
bread
cheese
chips
salsa
strawberry
watermelon
apples

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions