Created
September 3, 2012 07:16
-
-
Save QuanSai/3607528 to your computer and use it in GitHub Desktop.
Truth Table Tester - Asks the user a truth table-related question; Spits out correct answer if the answer provided is wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Created on Sep 03, 2012 | |
@author: Gregory A. Thompson Jr. | |
Truth Table Tester | |
booltest.py | |
-Asks the user a truth table-related question. | |
-Spits out correct answer if the answer provided is wrong. | |
''' | |
import random as ran | |
if __name__ == '__main__': | |
values = ['True', 'False'] | |
operators = ['and', 'or'] | |
while(True): | |
statement = ran.choice(values) + " " + ran.choice(operators) + " " + ran.choice(values) | |
nots = "not('" + statement + "')" | |
question = ran.choice([statement, nots]) | |
answer = eval(question) | |
usr_in = raw_input("The statement \"" + question + "\" is ") | |
if usr_in != str(answer): | |
print "Wrong!\a" | |
print "It was actually " + str(answer) + "." | |
else: | |
print "That's correct!" | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment