From e73c7c2bbf5db6253a787fe63917803d4d60d0d4 Mon Sep 17 00:00:00 2001 From: Dave LeCompte Date: Sat, 27 Feb 2021 18:55:29 -0800 Subject: [PATCH] Kinema tweak Moved the accuracy window constant to the top of the file with a comment. --- 52 Kinema/python/kinema.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/52 Kinema/python/kinema.py b/52 Kinema/python/kinema.py index 55d20aa1..e5529d68 100644 --- a/52 Kinema/python/kinema.py +++ b/52 Kinema/python/kinema.py @@ -14,6 +14,11 @@ import random g = 10 +# We only expect the student to get within this percentage of the +# correct answer. This isn't rocket science. + +EXPECTED_ACCURACY_PERCENT = 15 + def print_with_tab(spaces_count, msg): if spaces_count > 0: @@ -56,7 +61,9 @@ def do_quiz(): def ask_player(question, answer): print(question) player_answer = float(input()) - if abs((player_answer - answer) / answer) < 0.15: + + accuracy_frac = EXPECTED_ACCURACY_PERCENT / 100.0 + if abs((player_answer - answer) / answer) < accuracy_frac: print("CLOSE ENOUGH.") score = 1 else: