Fall 20019 Midterm: Dinner Time

Exam PDF

Text

  1. (20 points) Dinner Time!

It’s dinner time! We’re writing a function to check if we’re having a complete meal. Unscramble the following lines to complete the body of isCompleteMeal. You will use each line exactly once.

Given a list of 3 elements containing food items, return T rue if the 3 food items make a complete meal, meaning that it has one item from each category of appetizer, main, and dessert in no particular order. Return False if the meal is incomplete.

Parsons Code

has_app _______________
has_app _______________
return _______________ and _______________ and _______________ has_dessert _______________
has_dessert _______________
elif _______________:
elif _______________:
for _______________:
if _______________:
has_main _______________
has_main _______________

Example View

Midterm Page 5

Setup

    \q{20}{Dinner Time!}

It's dinner time! We're writing a function to check if we're having a complete meal. 

\textbf{Unscramble the following lines to complete the body of \texttt{isCompleteMeal}.} You will use each line exactly once.

Given a list of 3 elements containing food items, return $True$ if the 3 food items make a complete meal, meaning that it has one item from each category of appetizer, main, and dessert in no particular order. Return $False$ if the meal is incomplete.

\lstinputlisting{code/dinner-iscomplete-scrambled.py}

\solutionimage{
\lstinputlisting{code/dinner-iscomplete.py}
}{\lstinputlisting{code/dinner-iscomplete_sol.py}}


\textbf{Use your \texttt{isCompleteMeal} function to fill in \texttt{numCompleteMeals}.} You can get full points for this part even if your previous function isn't perfect. However, in order to get full credit, your solution must fit in one line of Python. 

If you can’t figure out a one line solution, but have a correct solution, you’ll still get some points! Oh, and if you write big, don’t worry about that. “One line” means one return statement.

\solutionimage{
\lstinputlisting{code/dinner-numcomplete.py}
}{\lstinputlisting{code/dinner-numcomplete_sol.py}}