In: Computer Science
Implement the following function by replacing the pass keyword with your code. Do not change the spelling of the function name or the parameter list.
def order_pie():
Important notes:
def order_pie(): pass
# There are only 7 possible sequences of questions.
# The sequence of inputs determines the output.
# Expected results:
# 'yes', 'yes' ---> [ 'apple pie', 'heated', 'strawberry ice cream', 'on the side' ]
# 'yes', 'no' ---> [ 'apple pie', 'heated', 'strawberry ice cream' ]
# 'no', 'yes', 'yes' ---> [ 'apple pie', 'heated', 'vanilla ice cream', 'on the side' ]
# 'no', 'yes', 'no' ---> [ 'apple pie', 'heated', 'vanilla ice cream' ]
# 'no', 'no', 'yes', 'yes' ---> [ 'apple pie', 'heated', 'whipped cream' ]
# 'no', 'no', 'yes', 'no' ---> [ 'apple pie' ]
# 'no', 'no', 'no' ---> [ 'apple pie' ]
def order_pie():
l=list(map(str,input().split()))
if(len(l)==2):
if(l.count('yes')==2):
return ['apple pie', 'heated', 'strawberry ice cream', 'on the
side' ]
else:
return [ 'apple pie', 'heated', 'strawberry ice cream' ]
elif(len(l)==3):
if(l.count('yes')==2 and l.count('no')==1):
return [ 'apple pie', 'heated', 'vanilla ice cream', 'on the side'
]
elif(l.count('yes')==1 and l.count('no')==2):
return [ 'apple pie', 'heated', 'vanilla ice cream' ]
elif(l.count('no')==3):
return [ 'apple pie' ]
elif(len(l)==4):
if(l.count('no')==2 and l.count('yes')==2):
return [ 'apple pie', 'heated', 'whipped cream' ]
elif(l.count('no')==3 and l.count('yes')==1):
return [ 'apple pie' ]
print(order_pie())