correct-first_3_planets.py
635 Bytes
#!/usr/bin/env python3
import re
import sys
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
# 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
grade = (len(correct) - len(wrong)) / len(planets)
out = f'''---
grade: {grade}'''
if grade < 1.0:
out += '\ncomments: Vou dar uma ajuda, as iniciais são M, V e T...'
print(out)
exit(0)