Print either "Fruit" or "Drink" (followed by a newline) depending on the value of userItem. For example, if userItem is GR_APPLES, output should be: Fruit

Respuesta :

The program illustrates the use of conditional statements.

Conditional statements in programming are statements that may or may not be executed. Their execution depends on the truth value of the condition.

The program in Python, where comments are used to explain each line is as follows

#This gets input from the user

userItem = input("Item: ")

#This checks if user input is GR_APPLES or GR_BANANAS

if(userItem == "GR_APPLES" or userItem == "GR_BANANAS"):

   #If yes, the program prints Fruit

   print("Fruit")

#if otherwise, this checks if user input is GR_JUICE or GR_WATER

elif (userItem == "GR_JUICE" or userItem == "GR_WATER"):

   #If yes, the program prints Drink

   print("Drink")

#If otherwise

else:

   #This prints Invalid

   print("Invalid")

See attachment for sample run

Read more about conditional statements at:

https://brainly.com/question/4211780

Ver imagen MrRoyal