We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Generate Who Wants to Be a Millionaire game that can be downloaded and played offline
Develop a GPT-driven “Who Wants to Be a Millionaire” game. You make 15 multiple choice questions with 1 being the easiest and 15 being the hardest. The dollar value determines how difficult the question is. This means $1000000 question is 10,000 times harder than $100 question. Make sure the first couple questions are really easy and the last few questions are incredibly hard.
Steps:
Make sure to run this code while generating questions. It is important that you randomize the answer choices.
import random
def create_question(question, correct_answer, wrong_answers):
"""
Creates a question with four choices (one correct, three wrong),
and returns the question along with the choices in random order,
and the index of the correct answer.
"""
choices = wrong_answers + [correct_answer]
random.shuffle(choices)
correct_index = choices.index(correct_answer)
return question, choices, correct_index
# $100 Question
question_100, choices_100, correct_index_100 = create_question(
"Which player is known for the phrase 'I'm taking my talents to South Beach'?",
"LeBron James",
["Michael Jordan", "Kobe Bryant", "Shaquille O'Neal"]
)
question_100, choices_100, correct_index_100
# $200 Question
question_200, choices_200, correct_index_200 = create_question(
"Which team won the NBA Championship in 2020?",
"Los Angeles Lakers",
["Miami Heat", "Toronto Raptors", "Golden State Warriors"]
)
question_200, choices_200, correct_index_200
questions
and set it to empty array. The file should look like this. questions = [];
questions.push({
value: 100,
question: "What is the standard height of a basketball hoop?",
answers: ["10 feet", "12 feet", "11 feet", "9 feet"],
correct: 0
});
// rest of questions
Take special care to make sure that the question
property has a proper JS string value (i.e. “ is properly escaped) and make sure that answers
have an array of proper JS strings (i.e. “ is properly escaped if it exists).
Make sure that MillionaireGPT.zip only has two files and it’s index.html and gpt.js.