Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. def ask_question(question, answer):
  2.     if input(question + "? ") == answer:
  3.         print("Risposta esatta")
  4.         return 1
  5.     else:
  6.         print("Risposta errata")
  7.         return 0
  8.  
  9. unpickled_list = [("domanda1", "risposta1"), ("domanda2", "risposta2"), ("domanda3", "risposta3")]
  10.  
  11. res = [ask_question(question, answer) for question, answer in unpickled_list]
  12.  
  13. print("Risposte corrette di Pari: {}".format(sum([res[i] for i in range(len(res)) if i % 2 == 0])))
  14. print("Risposte corrette di Dispari: {}".format(sum([res[i] for i in range(len(res)) if i % 2 == 0])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement