(PYTHON) (25 PTS)

Which of the following statements evaluates to true if the user picks a ham and cheese sandwich?

A - if(sandwich == "ham and cheese" and sandwich == "peanut butter and jelly"):
B - if(not(sandwich == "ham and cheese") and sandwich == "peanut butter and jelly"):
C - if(sandwich == "ham and cheese" or sandwich == "peanut butter and jelly"):
D - if(not(sandwich == "ham and cheese") or sandwich == "peanut butter and jelly"):

Respuesta :

The answer is C.
Option A will always return false, because a variable cannot be both "ham and cheese" and "peanut butter and jelly" simultaneously.Option B will return true if the user enters "peanut butter and jelly", because the condition is NOT "ham and cheese" AND "peanut butter and jelly".Option C will return true if the user enters "peanut butter and jelly" OR "ham and cheese.Option D will return true if the user does NOT enter "ham and cheese".
C is the only correct option.