import random import time def correct_and_valid ():#question logic random.shuffle(question["options"]) while True: # Loop until a proper choice is e.g.: a number between 1 and 4 money = money_list[question_number - 1] print(f"\nQuestion {question_number} for {money}: {question['questions']}")#prints the amount of money, question number, and the question for index, option in enumerate(question["options"], start=1):#this checks what question it is print(f"{index}. {option}") user_choice = input("Enter the number of your answer or enter 7 to use a lifeline: ")#checking if the player is entering their answer or asking for a hotline try: choice = int(user_choice)#makes sure the player choice is an int if 1 <= choice <= 4: selected_option = question["options"][choice - 1]#compares the player's answers with the actual answers if selected_option == question["answer"]: print("\nCorrect!") while question_number != 15: walk_away = input(f"\ndo you want to leave with {money}? (yes/no): ").lower() if walk_away in ("yes", "y"): print(f"see you next time {name}!") exit() elif walk_away in ("no", "n"): print("\nnext question") return else: print("\nInvalid input please enter yes or no") if question_number == 15: print("\nCongratulations you won $1,000,000") return else: print(f"\nsorry but your wrong the correct answer is {question['answer']}") if question_number >= 5: print("but you still get $1000 for passing the $1000 milestone at question number 5") elif question_number >= 10: print("but you still get $32000 for passing the $32000 milestone at question number 10") else: print("What a shame you didn't pass question 5 so you get no milestone reward") exit() elif choice == 7: lifeline() else: print("\nInvalid input. Please enter a number between 1 and 4, or 7 for a lifeline. ") except ValueError: print("\nInvalid input. Please enter a number between 1 and 4, or 7 for a lifeline.") def lifeline():#lifeline logic while True: try: lifeline_pick = (int(input("\nWould you like to\nCall a friend (1)\nAsk the audience (2)\n50/50 (3)\nenter the number of your choice ")))#checks what lifeline the player wants to use if lifeline_pick == 1: if lifeline_truefalse['lifeline_call']:#sees if the user has used the lifeline or not print("You’ve already used call a friend.") break lifeline_truefalse['lifeline_call'] = True print(f"\nYou chose Call a friend") pick_up = random.randint(1, 8)#7/8 of the time the friend answers 1/8 of the time they do not print("\nRing Ring Ring...") time.sleep(1) if pick_up <= 7: print("\nYou: Hello, I'm on who wants to be a millionaire and I need help with a question") print("\nFriend: That's nice, whats the question?") print(f"\nYou: The question is {question['questions']}") print(f"\nOh, I know the answer it is {question['answer']}") break if pick_up == 8: print("\nRing Ring Ring...") print("\nHost: What a shame they did not answer the phone") break elif lifeline_pick == 2: if lifeline_truefalse['lifeline_audience']: print("You’ve already used Ask the audience.") break lifeline_truefalse['lifeline_audience'] = True audience = random.randint(1, 100)#has a 91% chance of being wrong, this is based on some research I did print(f"\nYou choose to Ask the audience\nremember the audience can be wrong\nsurveying the audience...") time.sleep(1) if audience <=91: print(f"\nthe results are in the audience picked {question['answer']}") break if audience >=92: audience_two = random.randint(2, 4) print(f"\nthe results are in the audience picked {question['options'][audience_two]}") break elif lifeline_pick == 3: if lifeline_truefalse['lifeline_5050']: print("You’ve already used 50/50.") break lifeline_truefalse['lifeline_5050'] = True print(f"\nYou chose remove 2 wrong answers") incorrect_options = [option for option in question['options'] if option != question['answer']]#gets the incorrect options remove = random.sample(incorrect_options, 2) for item in remove: #removes two wrong choices question['options'].remove(item) print("Two wrong answers have been removed") break else: print("\nInvalid input. Please enter a number between 1 and 3.") except ValueError: print("\nInvalid input. Please enter a number between 1 and 3.") money_list = ["$100","$200","$300","$500","$1000","$2000","$4000","$8000","$16000","$32000","$64000","$125000","$250000","$500000","$1000000"] lifeline_truefalse = {#this is the dictionary that 'lifeline_call': False, 'lifeline_audience': False, 'lifeline_5050': False } question_list_easy = [ { "questions": "What is the capital of France?", "options": ["Paris", "London", "Berlin", "New York"], "answer": "Paris" }, { "questions": "Which animal is known as the king of the jungle?", "options": ["Lion", "Tiger", "Gorilla", "Elephant"], "answer": "Lion" }, { "questions": "How many continents are there in the world?", "options": ["7", "5", "8", "1"], "answer": "7" }, { "questions": "How many sides does a hexagon have?", "options": ["6", "8", "4", "7"], "answer": "6" }, { "questions": "What gas do humans breathe in to survive?", "options": ["Oxygen", "Carbon Dioxide", "Hydrogen", "Nitrogen"], "answer": "Oxygen" }, { "questions": "Which gas do plants absorb from the air?", "options": ["Carbon dioxide ", "Oxygen ", "Nitrogen", "Hydrogen"], "answer": "Carbon dioxide " }, { "questions": "How many legs does a spider have?", "options": ["8", "6", "9", "5"], "answer": "8" }, { "questions": "Which fruit is known for keeping the doctor away?", "options": ["Apple", "Banana", "Orange", "Grapes"], "answer": "Apple" }, { "questions": "What is the capital city of Japan?", "options": ["Tokyo", "Beijing", "Seoul", "Bangkok"], "answer": "Tokyo" }, { "questions": "Which animal is known as mans best friend?", "options": ["Dog", "Cat", "Rabbit", "Kangaroo"], "answer": "Dog" }, { "questions": "How many sides does a triangle have?", "options": ["3", "4", "2", "5"], "answer": "3" }, { "questions": "What is the freezing point of water in Celsius?", "options": ["0°c", "10°c", "-10°c", "5°c"], "answer": "0°c" }, { "questions": "Which superhero is also known as the 'Caped Crusader'?", "options": ["Batman", "Superman", "Ironman", "Spiderman"], "answer": "Batman" }, { "questions": "Which instrument has black and white keys?", "options": ["Piano", "Guitar", "Flute", "Violin"], "answer": "Piano" }, { "questions": "What do bees produce?", "options": ["Honey", "Suger", "Wax", "Pollen"], "answer": "Honey" }, { "questions": "Which shape has four equal sides and four right angles", "options": ["Square", "Rhombus", "Triangle", "Rectangle"], "answer": "Square" }, { "questions": "What is the opposite of “hot”?", "options": ["Cold", "Warm", "Dry", "Luke"], "answer": "Cold" }, { "questions": "Which planet is famous for its rings?", "options": ["Saturn", "Mars", "Uranus", "Neptune"], "answer": "Saturn" }, { "questions": "How many colors are there in a rainbow?", "options": ["7", "6", "8", "5"], "answer": "7" }, { "questions": "What do you get when you boil water?", "options": ["Steam", "Smoke", "Ice", "Air"], "answer": "Steam" }, { "questions": "Which animal is known for changing its color to blend in with its surroundings?", "options": ["Chameleon", "Parrot", "Kangaroo", "Koala"], "answer": "Chameleon" }, { "questions": "Which planet spins on its side, making its rotation unique among planets?", "options": ["Uranus", "Neptune", "Mars", "Venus"], "answer": "Uranus" }, { "questions": "Which city hosted the Summer Olympics in 2008?", "options": ["Beijing", "Sydney", "Seoul", "London"], "answer": "Beijing" }, { "questions": "Who discovered penicillin in 1928?", "options": ["Alexander Fleming", "Louis Pasteur ", "Marie Curie", "Edward Jenner "], "answer": "Alexander Fleming" }, { "questions": "How many hours are there in one day?", "options": ["10", "20", "24", "12"], "answer": "24" }, { "questions": "What color is a school bus typically painted?", "options": ["Red", "Blue", "Green", "Yellow"], "answer": "Yellow" }, { "questions": "Which day comes after Friday?", "options": ["Thursday", "Sunday", "Saturday", "Wednesday"], "answer": "Saturday" }, { "questions": "What do you call a baby frog?", "options": ["Tadpole", "Calf", "Puppy", "Hatchling"], "answer": "Tadpole" }, ]#List of easy questions question_list_medium = [ { "questions": "What planet is the closest to the sun?", "options": ["Mercury", "Mars", "Earth", "Jupiter"], "answer": "Mercury" }, { "questions": "What is the main ingredient in guacamole", "options": ["Avocado", "Tomato", "Cucumber", "Apple"], "answer": "Avocado" }, { "questions": "In computing, what does “CPU” stand for?", "options": ["Central Processing Unit", "Central Power Unit", "Core Processing Unit", "Computer Primary Unit"], "answer": "Central Processing Unit" }, { "questions": "Which continent is the Sahara Desert located on?", "options": ["Africa", "Asia", "Antarctica", "North America"], "answer": "Africa" }, { "questions": "Which language is primarily spoken in Brazil?", "options": ["Portuguese", "French", "Spanish", "Italian"], "answer": "Portuguese" }, { "questions": "Which country is home to the kangaroo?", "options": ["Australia", "India", "New Zealand", "Canada"], "answer": "Australia" }, { "questions": "What is the smallest prime number?", "options": ["2", "1", "0", "3"], "answer": "2" }, { "questions": "Which planet is known as the 'Red Planet'?", "options": ["Mars", "Venus", "Jupiter", "Saturn"], "answer": "Mars" }, { "questions": "Which country hosted the 2016 Summer Olympics?", "options": ["Brazil", "China", "UK", "Japan"], "answer": "Brazil" }, { "questions": "What is the term for animals that eat only plants?", "options": ["Herbivores", "Omnivores", "Carnivores", "Insectivores"], "answer": "Herbivores" }, { "questions": "Which part of the cell contains the genetic material?", "options": ["Nucleus", "Ribosome", "Cytoplasm", "Membrane"], "answer": "Nucleus" }, { "questions": "Who was the first person to step on the Moon?", "options": ["Neil Armstrong", "Buzz Aldrin", "Yuri Gagarin", "John Glenn"], "answer": "Neil Armstrong" }, { "questions": "What is the capital of New Zealand?", "options": ["Wellington", "Christchurch", "Dunedin", "Auckland"], "answer": "Wellington" }, { "questions": "Which country is known as the Land of the Rising Sun?", "options": ["Japan", "South Korea", "China", "Thailand"], "answer": "Japan" }, { "questions": "What is the chemical symbol for gold?", "options": ["Au", "Go", "Gu", "Ag"], "answer": "Au" }, { "questions": "In which year did World War II end?", "options": ["1945", "1969", "1946", "1943"], "answer": "1945" }, { "questions": "What is the square root of 256?", "options": ["16", "14", "18", "15"], "answer": "16" }, { "questions": "Which Greek philosopher taught Alexander the Great?", "options": ["Aristotle", "Pythagoras", "Plato", "Socrates"], "answer": "Aristotle" }, { "questions": "Which novel is subtitled “The Modern Prometheus”?", "options": ["Frankenstein", "The Invisible Man", "The Picture of Dorian Gray", "Dracula"], "answer": "Frankenstein" }, { "questions": "What is the SI unit of electrical resistance?", "options": ["Ohm", "Volt", "Ampere", "Watt"], "answer": "Ohm" }, { "questions": "In which country would you find the historic site of Petra?", "options": ["Jordan", "Turkey", "Greece", "Egypt"], "answer": "Jordan" }, { "questions": "Which part of the human brain controls balance and coordination?", "options": ["Cerebellum", "Cerebrum", "Medulla", "Hypothalamus"], "answer": "Cerebellum" }, { "questions": "Which U.S. landmark was a gift from France?", "options": ["Statue of Liberty", "Golden Gate Bridge", "Lincoln Memorial", "Mount Rushmore"], "answer": "Statue of Liberty" }, { "questions": "Which physicist coined the term 'black hole' in 1967?", "options": ["John Wheeler", "Stephen Hawking", "Albert Einstein", "Carl Sagan"], "answer": "John Wheeler" }, { "questions": "Which scientist proposed the three laws of planetary motion?", "options": ["Johannes Kepler", "Nicolaus Copernicus", "Issac Newton", "Galileo Galilei"], "answer": "Johannes Kepler" }, { "questions": "Which ancient civilization built Machu Picchu?", "options": ["Incas", "Aztecs", "Olmec's", "Mayans"], "answer": "Incas" }, { "questions": "Which painting is also called 'La Gioconda'?", "options": ["Mona Lisa", "The Birth of Venus", "Girl with a Pearl Earring", "The Last Supper"], "answer": "Mona Lisa" }, { "questions": "Which scientist developed the first successful polio vaccine in the 1950s?", "options": ["Jonas Salk", "Alexander Fleming", "Edward Jenner", "Albert Sabin"], "answer": "Jonas Salk" }, { "questions": "Which country is known for the Eiffel Tower?", "options": ["France", "Germany", "England", "Italy"], "answer": "France" }, { "questions": "Who invented the lightbulb?", "options":["Thomas Edison","BlueAlexander Graham Bell","Benjamin Franklin","Isaac Newton"], "answer":"Thomas Edison" }, { "questions": "What is the largest internal organ in the human body?", "options": ["Liver", "Brain", "Heart", "Kidney"], "answer": "Liver" }, { "questions": "What year did the Titanic sink?", "options": ["1912", "1910", "1920", "1916"], "answer": "1912" } ]#List of medium questions question_list_hard = [ { "questions": "Which author wrote the Harry Potter series?", "options": ["J.K. Rowling ", "J.R.R. Tolkien", "Rick Riordan ", "Suzanne Collins"], "answer": "J.K. Rowling " }, { "questions": "How many bones are there in the adult human body?", "options": ["206", "198", "214", "186"], "answer": "206" }, { "questions": "What is the currency of Brazil?", "options": ["Real", "Peso", "Lira", "Dollar"], "answer": "Real" }, { "questions": "Which painter is known for the artwork “The Persistence of Memory”?", "options": ["Salvador Dalí", "Edvard Munch", "Claude Monet", "Andy Warhol"], "answer": "Salvador Dalí" }, { "questions": "Which element has the chemical symbol “W”?", "options": ["Tungsten", "Tin", "Titanium", "Tellurium"], "answer": "Tungsten" }, { "questions": "What does the “E” stand for in email?", "options": ["Electronic", "Easy", "Express", "Extended"], "answer": "Electronic" }, { "questions": "Which ocean is the largest in the world?", "options": ["Pacific", "Arctic", "Indian", "Atlantic"], "answer": "Pacific" }, { "questions": "Who painted the ceiling of the Sistine Chapel?", "options": ["Michelangelo", "Leonardo da Vinci", "Raphael", "Donatello"], "answer": "Michelangelo" }, { "questions": "Which vitamin is primarily gained from sunlight?", "options": ["Vitamin D", "Vitamin C", "Vitamin A", "Vitamin B12"], "answer": "Vitamin D" }, { "questions": "What is the capital of Iceland?", "options": ["Reykjavik", "Copenhagen", "Helsinki", "Oslo"], "answer": "Reykjavik" }, { "questions": "Which country is both a continent and a country?", "options": ["Australia", "South Africa", "Antarctica", "Greenland"], "answer": "Australia" }, { "questions": "Which famous scientist developed the theory of general relativity", "options": ["Albert Einstein", "Nikola Tesla", "Galileo Galilei", "Isaac Newton"], "answer": "Albert Einstein" }, { "questions": "In Greek mythology, who is the king of the gods?", "options": ["Zeus", "Apollo", "Hades", "Poseidon"], "answer": "Zeus" }, { "questions": "What is the capital of Canada?", "options": ["Ottawa", "Montreal", "Vancouver", "Toronto"], "answer": "Ottawa" }, { "questions": "Which natural number comes after a trillion?", "options": ["Quadrillion", "Billion", "Centillion", "Quintillion"], "answer": "Quadrillion" }, { "questions": "Which animal is known to have the best memory?", "options": ["Elephant", "Cat", "Dog", "Horse"], "answer": "Elephant" }, { "questions": "Which is the only vowel not on the top row of a standard keyboard?", "options": ["A", "I", "E", "U"], "answer": "A" }, { "questions": "Which novel begins with the line, 'Call me Ishmael'?", "options": ["Moby Dick", "The Great Gatsby", "To Kill a Mockingbird", "Dracula"], "answer": "Moby Dick" }, { "questions": "Which British mathematician is considered the founder of computer science and helped crack Nazi codes during WWII?", "options": ["Alan Turing", "Stephen Hawking", "Charles Babbage", "Isaac Newton"], "answer": "Alan Turing" }, { "questions": "Which of these chemical elements is named after a real-life scientist?", "options": ["Einsteinium", "Curium", "Californium", "Berkelium"], "answer": "Einsteinium" }, { "questions": "Which element has the highest melting point?", "options": ["Tungsten", "Carbon", "Iron", "Platinum"], "answer": "Tungsten" }, { "questions": "In which layer of Earth's atmosphere does the ozone layer lie?", "options": ["Stratosphere", "Troposphere", "Mesosphere", "Thermosphere"], "answer": "Stratosphere" }, { "questions": "The Parthenon is located in which city?", "options": ["Athens", "Rome", "Cairo", "Istanbul"], "answer": "Athens" } ]#List of hard questions question_number = 0 name = input("What is your name? ") print(f"\nwelcome to who wants to be a millionaire {name}") while True: rules = input(f"\ndo you want to know how to play who wants to be a millionaire {name}? ").lower() if rules in ("yes","y"): print("\n ---How to play---\n\nI will ask you a set of questions, and you will answer them.") print("\n ---getting questions correct---\n\nIf you get a question correct, you pass on to the next question. With 15\nquestions total, you get a set amount of ‘money’ for each question correct,\nstarting from $100 and ending with $1,000,000, and you can ‘walk away’ with\nthe amount of money you have after answering a question correctly.") print("\n ---getting questions wrong---\n\nIf you get a question wrong, you lose all the money you’ve earned so far\nhowever, all hope is not lost just yet. If you pass questions 5 and 10, you\nstill get $1,000 and $32,000 respectively") print("\n ---Lifelines---\n\nLifelines are helpful if you get stuck on a question and can’t think of an\nanswer. The lifelines you get are ask the audience (do a 'poll' that asks\nthe audience what the answer is), call a friend(calls a friend and asks\nthem for the answer to the question), and 50/50(removes two wrong answers\nleaving only one correct and one wrong). But be careful because you can\nonly use lifelines once each.") print(f"\nThat's all the rules good luck {name}") break elif rules in ("no","n"): print(f"\nOk good luck {name}") break else: print("\nInvalid input, please enter yes or no") for i in range(1, 6): question_number += 1#counts the questions question = random.choice(question_list_easy) correct_and_valid()#calls the function which grabs a question from the list and displays it question_list_easy.remove(question)#removes the question so it doesn't repeat for i in range(1, 6): question_number += 1 question = random.choice(question_list_medium) correct_and_valid() question_list_medium.remove(question) for i in range(1, 6): question_number += 1 question = random.choice(question_list_hard) correct_and_valid() question_list_hard.remove(question)