Write a Python program that produces a truth table for the following statements:
- p and q
- p or q
- if p, then q
- p if and only if q
To earn credit, you must calculate the truth values.
我可以使用:
print(getSym(p), getSym(q), getSym(p and q), getSym(p or q),
找出“and”和“or”语句
def getSym(x):
if x:
return 'T'
else:
return 'F'
values = [True, False]
print('and')
for p in values:
for q in values:
print(getSym(p), getSym(q), getSym(p and q), getSym(p or q), getSym())
我已经得到了前两个语句来输出一个正确的真值表
您需要使用和/或等效项
你能从那里拿走吗?你知道吗
相关问题 更多 >
编程相关推荐