summaryrefslogtreecommitdiff
path: root/courses.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2020-05-06 17:23:41 +0200
committerOlivier Gayot <olivier.gayot@sigexec.com>2020-05-06 17:23:41 +0200
commit6c967292b01b1dde301cd8d607b93a50f0712c32 (patch)
tree9c729eedb01ac7633e0766cc8edd4af43f8a55e8 /courses.py
parent06bb76c279f1fd2f8e7806033e44f1eaa8779561 (diff)
Renamed to courses and use course selectionHEADmaster
Signed-off-by: Olivier Gayot <olivier.gayot@murex.com> Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'courses.py')
-rwxr-xr-xcourses.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/courses.py b/courses.py
new file mode 100755
index 0000000..50642f7
--- /dev/null
+++ b/courses.py
@@ -0,0 +1,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()