„question_answer_output.py“ löschen
This commit is contained in:
parent
602d0a1ab4
commit
cd58a96b41
|
@ -1,24 +0,0 @@
|
|||
import json
|
||||
from random import randrange
|
||||
|
||||
|
||||
# Einlesen vom Json File
|
||||
def read_json(filename):
|
||||
with open(filename,encoding='utf-8') 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 #{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])
|
||||
|
Loading…
Reference in New Issue
Block a user