ich habe ein sehr einfaches Programm geschrieben und würde gerne Kommentare bekommen. Grundsätzlich frage ich mich ob den Stil mehr oder weniger gut ist und auch ob man das ganze mit wenigen Zeilen schreiben kann.
Code: Alles auswählen
lnot_equal = "!="
lequal = "=="
lgreater_equal = ">="
lless_equal = "<="
lnot_false = "True"
lnot_false2 = "true"
lnot_true = "False"
lnot_true2 = "false"
ltrue_false = "True"
ltrue_false2 = "true"
ltrue_true = "True"
ltrue_true2 = "true"
lfalse_true = "True"
lfalse_true2 = "true"
lfalse_false = "False"
lfalse_false2 = "false"
ltrue_and_false = "False"
ltrue_and_false2 = "false"
ltrue_and_true = "True"
ltrue_and_true2 = "true"
lfalse_and_true = "False"
lfalse_and_true2 = "false"
lfalse_and_false = "False"
lfalse_and_false2 = "false"
lnottrue_or_false = "False"
lnottrue_or_false2 = "false"
lnottrue_or_true = "False"
lnottrue_or_true2 = "false"
lnotfalse_or_true = "False"
lnotfalse_or_true2 = "false"
lnotfalse_or_false = "True"
lnotfalse_or_false2 = "true"
lnottrue_and_false = "True"
lnottrue_and_false2 = "true"
lnottrue_and_true = "False"
lnottrue_and_true2 = "false"
lnotfalse_and_true = "True"
lnotfalse_and_true2 = "true"
lnotfalse_and_false = "True"
lnotfalse_and_false2 = "true"
prompt = "> "
print ("\n\tThe Truth Terms\n")
print ("How is not equal?")
not_equal = input(prompt)
if not_equal == lnot_equal:
print ("Right")
else:
print ("Incorrect")
print ("How is equal?")
equal = input(prompt)
if equal == lequal:
print ("Right")
else:
print ("Incorrect")
print ("How is greater than equal?")
greater_equal = input(prompt)
if greater_equal == lgreater_equal:
print ("Right")
else:
print ("Incorrect")
print ("How is less than equal?")
less_equal = input(prompt)
if less_equal == lless_equal:
print ("Right")
else:
print ("Incorrect")
print ("not False?")
not_false = input(prompt)
if not_false == lnot_false or not_false == lnot_false2:
print ("Right")
else:
print ("Incorrect")
print ("not True?")
not_true = input(prompt)
if not_true == lnot_true or not_true == lnot_true2:
print ("Right")
else:
print ("Incorrect")
print ("True or False?")
true_false = input(prompt)
if true_false == ltrue_false or true_false == ltrue_false2:
print ("Right")
else:
print ("Incorrect")
print ("True or True?")
true_true = input(prompt)
if true_true == ltrue_true or true_true == ltrue_true2:
print ("Right")
else:
print ("Incorrect")
print ("False or True?")
false_true = input(prompt)
if false_true == lfalse_true or false_true == lfalse_true2:
print ("Right")
else:
print ("Incorrect")
print ("False or False?")
false_false = input(prompt)
if false_false == lfalse_false or false_false == lfalse_false2:
print ("Right")
else:
print ("Incorrect")
print ("True and False?")
true_and_false = input(prompt)
if true_and_false == ltrue_and_false or true_and_false == ltrue_and_false2:
print ("Right")
else:
print ("Incorrect")
print ("True and True?")
true_and_true = input(prompt)
if true_and_true == ltrue_and_true or true_and_true == ltrue_and_true2:
print ("Right")
else:
print ("Incorrect")
print ("False and True?")
false_and_true = input(prompt)
if false_and_true == lfalse_and_true or false_and_true == lfalse_and_true2:
print ("Right")
else:
print ("Incorrect")
print ("False or False?")
false_and_false = input(prompt)
if false_and_false == lfalse_and_false or false_and_false == lfalse_and_false2:
print ("Right")
else:
print ("Incorrect")
print ("not (True or False)?")
nottrue_or_false = input(prompt)
if (nottrue_or_false == lnottrue_or_false
or nottrue_or_false == lnottrue_or_false2):
print ("Right")
else:
print ("Incorrect")
print ("not (True or True)?")
nottrue_or_true = input(prompt)
if (nottrue_or_true == lnottrue_or_true
or nottrue_or_true == lnottrue_or_true2):
print ("Right")
else:
print ("Incorrect")
print ("not (False or True)?")
notfalse_or_true = input(prompt)
if (notfalse_or_true == lnotfalse_or_true
or notfalse_or_true == lnotfalse_or_true2):
print ("Right")
else:
print ("Incorrect")
print ("not (False or False)?")
notfalse_or_false = input(prompt)
if (notfalse_or_false == lnotfalse_or_false
or notfalse_or_false == lnotfalse_or_false2):
print ("Right")
else:
print ("Incorrect")
print ("not (True and False)?")
nottrue_and_false = input(prompt)
if (nottrue_and_false == lnottrue_and_false
or nottrue_and_false == lnottrue_and_false2):
print ("Right")
else:
print ("Incorrect")
print ("not (True and True)?")
nottrue_and_true = input(prompt)
if (nottrue_and_true == lnottrue_and_true
or nottrue_and_true == lnottrue_and_true2):
print ("Right")
else:
print ("Incorrect")
print ("not (False and True)?")
notfalse_and_true = input(prompt)
if (notfalse_and_true == lnotfalse_and_true or
notfalse_and_true == lnotfalse_and_true2):
print ("Right")
else:
print ("Incorrect")
print ("not (False and Fasle)?")
notfalse_and_false = input(prompt)
if (notfalse_and_false == lnotfalse_and_false or
notfalse_and_false == lnotfalse_and_false2):
print ("Right")
else:
print ("Incorrect")
print ("\n\tRemember\n")
istrue = """
1 != 0 => True
1 != 1 => False
0 != 1 => True
0 != 0 => False
1 == 0 => False
1 == 1 => True
0 == 1 => False
0 == 0 => True
"""
print (istrue)