Untitled

Anonymous
plain_text
03/15/2026 2:22 PM
5.9 KB
14
Indexable
import time
# CORRECT ANSWER WILL BE EITHER B OR C
MATH_EASY = "What is 1+1?"
MATH_EASY_OPTION = """
A. 1
B. 2
C. 3
D. 100
"""
MATH_EASY_CORRECT = "b"

MATH_NORMAL = "What is 50+49?"
MATH_NORMAL_OPTION = """
A. 97
B. 98
C. 99
D. 100
"""
MATH_NORMAL_CORRECT = "c"

MATH_HARD = "What is 60*40?"
MATH_HARD_OPTION = """
A. 2000
B. 2200
C. 2400
D. 2600
"""
MATH_HARD_CORRECT = "c"

SCI_EASY = "What is freezing temp in C?"   # answer: B
SCI_EASY_OPTION = """
A. -10
B. 0
C. 10
D. 32
"""
SCI_EASY_CORRECT = "b"

SCI_NORMAL = "What is Einstein's first name?"   # answer: B
SCI_NORMAL_OPTION = """
A. Isaac
B. Albert
C. Nikola
D. Thomas
"""
SCI_NORMAL_CORRECT = "b"

SCI_HARD = "What state is mercury at room temperature?"   # answer: C
SCI_HARD_OPTION = """
A. Solid
B. Gas
C. Liquid
D. Plasma
"""
SCI_HARD_CORRECT = "c"


ENG_EASY = "What are the first three letters of the alphabet?"   # answer: C
ENG_EASY_OPTION = """
A. abe
B. abd
C. abc
D. bcd
"""
ENG_EASY_CORRECT = "c"

ENG_NORMAL = "What does ESL stand for?"   # answer: C
ENG_NORMAL_OPTION = """
A. English Second Language
B. English Study Level
C. English as a Second Language
D. Elementary School Learning
"""
ENG_NORMAL_CORRECT = "c"

ENG_HARD = "What is Shakespeare's most famous work?"   # answer: B
ENG_HARD_OPTION = """
A. Macbeth
B. Hamlet
C. Romeo and Juliet
D. Othello
"""
ENG_HARD_CORRECT = "b"


score = 0


# sub program skills or sum: score saver/ double points for question
# deduct players point for using skill
# turn answers into upper or lowercase all so then more flexible answer, no case sensitive
# output score at the end
# Return player to menu

def ask_single_question(question, choices, correct_choice, award):
    global score
    print()
    print(question)
    print(choices)
    answer = input("Enter your answer here: ")
    if answer.lower() == correct_choice:
        print("You are correct.")
        print()
        print("Your current score is", score)
        score = score + award
        print(f"Your score is increased by {award}. The updated score is:", score)
    else:
        print("You are wrong.")
        print("Your current score is", score)
    print()

def ask_math_questions():
    ask_single_question(MATH_EASY, MATH_EASY_OPTION, MATH_EASY_CORRECT, 5)
    ask_single_question(MATH_NORMAL, MATH_NORMAL_OPTION, MATH_NORMAL_CORRECT, 10)
    ask_single_question(MATH_HARD, MATH_HARD_OPTION, MATH_HARD_CORRECT, 15)
    

def ask_sci_questions():
    ask_single_question(SCI_EASY, SCI_EASY_OPTION, SCI_EASY_CORRECT, 5)
    ask_single_question(SCI_NORMAL, SCI_NORMAL_OPTION, SCI_NORMAL_CORRECT, 10)
    ask_single_question(SCI_HARD, SCI_HARD_OPTION, SCI_HARD_CORRECT, 15)
    
def ask_eng_questions():
    ask_single_question(ENG_EASY, ENG_EASY_OPTION, ENG_EASY_CORRECT, 5)
    ask_single_question(ENG_NORMAL, ENG_NORMAL_OPTION, ENG_NORMAL_CORRECT, 10)
    ask_single_question(ENG_HARD, ENG_HARD_OPTION, ENG_HARD_CORRECT, 15)

print("WELCOME TO THE GAME")
print()

CHOSEN_PLACEHOLDER = "ALREADY_CHOSEN"
prompt = "Choose 1 for Math, 2 for Science, 3 for English"

score = 0
available_topics = ["Math", "Science", "English"]
#                     0         1         2

while True:
    print("Please choose among the available topics: ")
    for topic in available_topics:
        if topic != CHOSEN_PLACEHOLDER:
            print("-", topic)
            
    print(prompt)
    print()
    selection = int(input("Choose your option. Enter a valid integer: "))

    
    if selection < 1 or selection > 3:
        print()
        print("You chose an invalid topic, please enter an integer from 1 to 3")
        print()
        continue
    
    topic_index = selection - 1
    chosen_topic = available_topics[topic_index]
    if chosen_topic == CHOSEN_PLACEHOLDER:
        print()
        print("The topic is already chosen, please choose another one")
        print()
        continue
    
    available_topics[topic_index] = CHOSEN_PLACEHOLDER
    
    if selection == 1:
        ask_math_questions()
    elif selection == 2:
        ask_sci_questions()
    elif selection == 3:
        ask_eng_questions()
    
    if available_topics == [CHOSEN_PLACEHOLDER, CHOSEN_PLACEHOLDER, CHOSEN_PLACEHOLDER]:
        break
    print()

print("Congratz, you have finished the game. Your final score is")
print(score)
print("Game exited!")
Editor is loading...
Leave a Comment