Quizzma Latest Questions

Write a program that prompts the user for a meal: breakfast, lunch, or dinner. Then, use conditional statements to check the user’s input. If the user selects “breakfast,” respond with a meal suggestion for breakfast. For example if the meal was “breakfast”, you could say something like, “How about some avocado on toast?” If the user selects “lunch,” respond with a meal suggestion for lunch. If the user selects “dinner,” respond with a meal suggestion for dinner. If the user enters anything other than these three options, provide a message indicating that the input is not valid

Write a program that prompts the user for a meal: breakfast, lunch, or dinner. Then, use conditional statements to check the user’s input.

If the user selects “breakfast,” respond with a meal suggestion for breakfast. For example if the meal was “breakfast”, you could say something like, “How about some avocado on toast?”

If the user selects “lunch,” respond with a meal suggestion for lunch.

If the user selects “dinner,” respond with a meal suggestion for dinner.

If the user enters anything other than these three options, provide a message indicating that the input is not valid.




Leave an answer

Leave an answer

What is the capital of Egypt? ( Cairo )

1 Answer

  1. Here’s a simple Python program that performs the task you described:

    
    

    # Prompt the user for a meal choice

    meal = input("Please enter a meal (breakfast, lunch, or dinner): ").lower()

    # Use conditional statements to check the user's input

    if meal == "breakfast":

    print("How about some avocado on toast?")

    elif meal == "lunch":

    print("How about a delicious turkey sandwich?")

    elif meal == "dinner":

    print("How about grilled salmon with vegetables?")

    else:

    print("That's not a valid meal option! Please select breakfast, lunch, or dinner.")

    ### Explanation:
    1. Input: The program prompts the user to enter a meal option and converts the input to lowercase to ensure consistency.
    2. Conditional Statements: The program checks the user’s input using `if`, `elif`, and `else` statements.

    – If the input is “breakfast,” it suggests a breakfast idea.

    – If it’s “lunch,” it suggests a lunch idea.

    – If it’s “dinner,” it suggests a dinner idea.

    – If the input is not one of the three options, it informs the user that the input is invalid.

    Feel free to ask if you have any questions or want to learn more about a specific part of the code!

Related Questions