import random
QUESTIONS = [
{
"question": "Wer hat das Gemälde 'Die Nachtwache' gemalt?",
"options": ["Rembrandt", "Vermeer", "Van Gogh", "Monet"],
"answer": "Rembrandt"
},
{
"question": "Wie heißt das Gemälde mit der berühmten Mona Lisa?",
"options": ["Starry Night", "The Persistence of Memory", "Water Lilies", "La Gioconda"],
"answer": "La Gioconda"
},
{
"question": "Welcher Künstler hat die Skulptur 'David' geschaffen?",
"options": ["Michelangelo", "Donatello", "Raphael", "Leonardo da Vinci"],
"answer": "Michelangelo"
},
{
"question": "Wer hat das Gemälde 'Die Schrei' gemalt?",
"options": ["Vincent van Gogh", "Edvard Munch", "Pablo Picasso", "Salvador Dali"],
"answer": "Edvard Munch"
},
{
"question": "Wie heißt das Kunstwerk mit einem Haufen Bananen?",
"options": ["Campbell's Soup Cans", "The Physical Impossibility of Death in the Mind of Someone Living", "Three Flags", "The Bananas of Andy Warhol"],
"answer": "The Bananas of Andy Warhol"
},
{
"question": "Wer hat das Kunstwerk 'Fontäne' geschaffen?",
"options": ["Marcel Duchamp", "Salvador Dali", "Henri Matisse", "Edgar Degas"],
"answer": "Marcel Duchamp"
},
{
"question": "Wie heißt das Werk von Vincent van Gogh, das einen Sternenhimmel zeigt?",
"options": ["Sunflowers", "The Starry Night", "Irises", "Café Terrace at Night"],
"answer": "The Starry Night"
},
{
"question": "Welcher Künstler hat das Werk 'Campbell's Suppendosen' geschaffen?",
"options": ["Andy Warhol", "Roy Lichtenstein", "Claes Oldenburg", "Jasper Johns"],
"answer": "Andy Warhol"
},
{
"question": "Wer hat das Gemälde 'Die Geburt der Venus' gemalt?",
"options": ["Sandro Botticelli", "Leonardo da Vinci", "Raphael", "Michelangelo"],
"answer": "Sandro Botticelli"
}
]
def run_game():
score = 0
random.shuffle(QUESTIONS)
for i, q in enumerate(QUESTIONS):
print(f"Frage {i+1}: {q['question']}")
for j, option in enumerate(q['options']):
print(f"{j+1}: {option}")
answer = int(input("Antwort: ")) - 1
if q['options'][answer] == q['answer']:
print("Korrekt!")
score += 1
else:
print(f"Falsch. Die richtige Antwort ist {q['answer']}")
print()
print(f"Sie haben {score} von {len(QUESTIONS)} Fragen richtig beantwortet.")
if __name__ == '__main
# API-Endpunkt zum Überprüfen der ausgewählten Antwort
@app.route('/check', methods=['POST'])
def check_answer():
answer = request.json['answer']
correct_answer = request.json['correct_answer']
if answer == correct_answer:
response = {'result': 'correct'}
else:
response = {'result': 'incorrect'}
return jsonify(response)
# Hauptfunktion zum Ausführen des Spiels
def run_game():
# Zufällige Frage und Antwort auswählen
index = random.randint(0, len(QUESTIONS) - 1)
question = QUESTIONS[index]
answer = ANSWERS[index]
# Antworten mischen
answers = [answer]
while len(answers) < 4:
random_index = random.randint(0, len(ANSWERS) - 1)
random_answer = ANSWERS[random_index]
if random_answer != answer and random_answer not in answers:
answers.append(random_answer)
random.shuffle(answers)
# HTML-Seite generieren
html = '
' + question + '
'
for i, answer in enumerate(answers):
html += ''
html += ''
html += ''
# HTML-Seite in Webbrowser öffnen
with open('index.html', 'w') as file:
file.write(html)
webbrowser.open('index.html')
# Hauptfunktion zum Starten des Servers
if __name__ == '__main__':
app.run()