schooldevelopment

My python quiz

def ask_question(country, capital): answer = input(f”What is the capital of {country}? “).strip().lower() return answer == capital.lower()

def run_quiz(): print(“=== Country Capitals Quiz ===”) print(“Type your answers and press Enter.\n”)

questions = {
    "France": "Paris",
    "Japan": "Tokyo",
    "Australia": "Canberra",
    "Canada": "Ottawa",
    "Brazil": "Brasília"
}

score = 0

for country, capital in questions.items():
    if ask_question(country, capital):
        print("Correct!\n")
        score += 1
    else:
        print(f"Incorrect. The capital of {country} is {capital}.\n")

print(f"Your final score: {score}/{len(questions)}")
if score == len(questions):
    print("Excellent work!")
elif score >= 3:
    print(" Good job! Keep practicing.")
else:
    print("You might want to study a bit more.")

if name == “main”: run_quiz()