Sandwich Chooser

This practice assignment deals with two big ideas of if/else code:

  • nested if/else – if statement inside another if statement
  • compound boolean expressions: conditions using and / or

These are different ways to give your program more than two possible outcomes.


Write a short piece of Python code to help your user choose which sandwich to buy.

You will need to ask them two questions, and using their answers, recommend a sandwich.
(If you want to write the program for some other type of food, like pasta or pizza or soup, that is fine!)

For example, you could ask “hot or cold”, if they eat meat, if they eat dairy, and so on. You get to pick the two questions, and you pick 4 different types of sandwich that can be recommended depending on their answers.

Focus on the programming and don’t waste 20+ minutes writing your sandwich questions.

There are two basic ways to write this program.

1) Nested if/else logic. You can see a very close example in the nested if/else notes on nemoquiz.com that will show you how this looks.

2) Compound boolean along with if/elif/else structure. This means you will use the “and” word in your if statements. This lets you avoid using a nested structure. (the link above also shows a “non-nested” version of the pizza example).

Write your program in BOTH of these ways. It should work the same either way.
(Learning more than one way to code something makes you a better programmer, and thinking about which way to do it will help you choose better ways to program something)

At the very end of your code, write a comment that says which of these two methods you prefer in this case, and why. This part is purely your opinion, so you can’t be wrong.

Remember, you are writing TWO versions of this program. One version has nested if/else, and the other version uses if/elif/elif/else logic instead.