24.0k views
4 votes
Write a code segment that prints the food item associated with selection. For example, if selection is 3, the code segment should print "pasta".

Write the code segment below. Your code segment should meet all specifications and conform to the example.

1 Answer

5 votes

Missing Part:

Assume that the following variables have been properly declared and initialized: an int variable named selection, where 1 represents "beef", 2 represents "chicken", 3 represents "pasta", and all other values represent "fish"

Answer:

if selection == 1:

print("beef")

elif selection == 2:

print("chicken")

elif selection ==3:

print("pasta")

else:

print("fish")

Step-by-step explanation:

I've completer the question and the questin will be answered in python.

This checks if selection is 1. If yes, it prints the beef

if selection == 1:

print("beef")

This checks if selection is 2. If yes, it prints the chicken

elif selection == 2:

print("chicken")

This checks if selection is 3. If yes, it prints the pasta

elif selection ==3:

print("pasta")

Any other input is considered java/

else:

print("fish")

User IndigoChild
by
5.5k points