From 1154a9101a1dd7c3f9bf78c653c7c052b9d01316 Mon Sep 17 00:00:00 2001 From: Miguel Barão Date: Wed, 8 May 2019 15:54:08 +0100 Subject: [PATCH] minor changes in demo/solar_system/correct-first_3_planets.py --- demo/solar_system/correct-first_3_planets.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/demo/solar_system/correct-first_3_planets.py b/demo/solar_system/correct-first_3_planets.py index 03ea62e..760eded 100755 --- a/demo/solar_system/correct-first_3_planets.py +++ b/demo/solar_system/correct-first_3_planets.py @@ -2,26 +2,27 @@ import re import sys +import time s = sys.stdin.read() -# set of words converted to lowercase -answer = set(re.findall(r'[\w]+', s.lower())) -answer.difference_update({'e', 'a', 'planeta', 'planetas'}) # ignore these +ans = set(re.findall(r'[\w]+', s.lower())) # convert answer to lowercase +ans.difference_update({'e', 'a', 'o', 'planeta', 'planetas'}) # ignore words # correct set of planets planets = {'mercúrio', 'vénus', 'terra'} -correct = set.intersection(answer, planets) # the ones I got right -wrong = set.difference(answer, planets) # the ones I got wrong +correct = set.intersection(ans, planets) # the ones I got right +wrong = set.difference(ans, planets) # the ones I got wrong grade = (len(correct) - len(wrong)) / len(planets) +comments = 'Certo' if grade == 1.0 else 'as iniciais dos planetas são M, V e T' + out = f'''--- -grade: {grade}''' +grade: {grade} +comments: {comments}''' -if grade < 1.0: - out += '\ncomments: Vou dar uma ajuda, as iniciais são M, V e T...' +time.sleep(5) print(out) -exit(0) -- libgit2 0.21.2