You can download this code by clicking the button below.
This code is now available for download.
This function uses the PyInquirer library to create a simple interactive interface where the user can choose an answer from predefined questions.
Technology Stack : PyInquirer
Code Type : Interactive code
Code Difficulty : Intermediate
def select_random_question():
import random
from pyinquirer import List, Prompt
questions = [
"What is your favorite color?",
"Which programming language do you prefer?",
"Do you prefer to work with Python or JavaScript?"
]
prompt = Prompt(
questions=random.choice(questions)
)
response = prompt.prompt()
return response