[Python] Restaurant Selector program

Discussão em 'Python' iniciado por Stack, Julho 17, 2025.

  1. Stack

    Stack Membro Participativo

    I have a coding problem to solve. I did a half but I can't figure out rest.

    Here is the problem:


    You have a group of friends coming to visit for your high school reunions, and you want to take them out to eat at a local restaurant. You aren't sure if any of them have dietary restrictions, but your restaurant choices are as follows:

    Joe's Gourmet Burgers - Vegetarian: No, Vegan: No, Gluten-Free: No
    Main Street Pizza Company - Vegetarian: Yes, Vegan: No, Gluten-Free: Yes
    Corner Cafe - Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes
    Mama's Fine Italian - Vegetarian: Yes, Vegan: No, Gluten-Free: No
    The Chef's Kitchen - Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes

    Write a program that asks whether any numbers of your party are vegetarian, vegan, or gluten-free, to which then displays only the restaurants to which you may take the group.
    ​

    Here is an example of the program's output:

    Is anyone in your party a vegetarian ? yes
    Is anyone in your party a vegan ? no
    Is anyone in your party gluten-free ? yes
    Here are your restaurant choices:
    Main Street Pizza Company
    Corner Cafe
    The Chef's Kitchen


    Here is another example of the program's output:

    Is anyone in your party a vegetarian ? yes
    Is anyone in your party a vegan ? yes
    Is anyone in your party gluten-free ? yes
    Here are your restaurants choices:
    Corner Cafe
    The Chef's Kitchen


    Here is the code I wrote so far:

    # Get the status of a party
    vegetarian = input('Is anyone in your party a vegetarian(yes/no)? ')
    vegan = input('Is anyone in your party a vegan(yes/no)? ')
    gluten_free = input('Is anyone in your party gluten-free(yes/or)? ')

    # Assign restaurants based on the status of a party
    if vegetarian == 'yes' and vegan == 'yes' and gluten_free == 'yes':
    print("Here are your restaurant choices: \n"
    "Corner Cafe \n"
    "The Chef's Kitchen")
    elif vegetarian == 'no' and vegan == 'no' and gluten_free == 'no':
    print("Here are your restaurant choices: \n"
    "Joe's Gourmet Burgers")


    Here is the output:

    Is anyone in your party a vegetarian(yes/no)? yes
    Is anyone in your party a vegan(yes/no)? yes
    Is anyone in your party gluten-free(yes/or)? yes
    Here are your restaurant choices:
    Corner Cafe
    The Chef's Kitchen


    Is anyone in your party a vegetarian(yes/no)? no
    Is anyone in your party a vegan(yes/no)? no
    Is anyone in your party gluten-free(yes/or)? no
    Here are your restaurant choices:
    Joe's Gourmet Burgers


    What I want is to write a statement that selects restaurants randomly based on the answers.
    But I can figure out how.
    Can someone tell me how to do it, please ??
    I didn't google. I want to learn. Not to copy. Thank you in advance.

    Continue reading...

Compartilhe esta Página