Pruefungskatalog/question_answer_output.py
2022-03-21 15:46:51 +01:00

26 lines
669 B
Python

# TODO: einlesen der berreits vorhanden Daten im JSON File
import json
from random import randrange
# Einlesen Json File
def read_json(filename):
with open(filename) as filename:
data = json.load(filename)
return data
# Zufällige Frage erstellen
def random_question(filename):
min = 0
max = len(read_json(filename))
random_number = randrange(min,max)
questions = read_json(filename)
question = f'Frage Nr:', random_number, questions[random_number][str(random_number)]['question']
answer = questions[random_number][str(random_number)]['answer']
return question, answer
#print(random_question(config.json_file)[0])