blob: 50642f7b40a560ab2ca02301f4c816df521c8258 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/usr/bin/env python3
import json
import random
def main():
courses = json.load(open("courses.json", mode="r", encoding="utf-8"))
for i, course in enumerate(courses):
print(f"{i + 1}. {course['name']}: {course['description']}")
print(f"Which course do you want to run? [1-{len(courses)}] ", end="")
course = courses[int(input()) - 1]
assert course["name"] == "english-very"
dictionary = course["data"]
correct = 0
for counter, (question, answer) in enumerate(random.sample(dictionary, len(dictionary))):
print(f"Very {question} -> ", end="")
try:
user_input = input()
except EOFError:
break
if user_input.lower() == answer.lower():
print("Correct!")
correct += 1
else:
print(f"Wrong! The answer was {answer}")
print(f"Result: {correct}/{counter}")
if __name__ == "__main__":
main()
|