GITLAB

Miguel Barão / perguntations

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 1
  • Merge Requests 0
  • Wiki
  • perguntations
  • demo
  • questions
  • correct
  • correct-question.py
  • f6b63c71   changes to demo scripts Browse Code »
    Miguel Barão
    2019-02-13 15:43:05 +0000  
correct-question.py 402 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/env python3

import re
import sys

msg1 = '''---
grade: 1.0
comments:  Muito bem!
'''

msg0 = '''
grade: 0.0
comments: A resposta correcta é "red green blue".
'''

s = sys.stdin.read()

answer = set(re.findall(r'[\w]+', s.lower()))  # get words in lowercase
rgb_colors = set(['red', 'green', 'blue'])     # the correct answer

if answer == rgb_colors:
    print(msg1)
else:
    print(msg0)