python學習----誰在說謊邏輯運算

飞虎就是我發表於2024-05-09
if __name__ == '__main__':
Li = [0, 1]
for a in Li:
for b in Li:
for c in Li:
zhang = (b == 0)
li = (c == 0)
wang = (a+b == 0)
if (zhang+li+wang == 2 and a+b+c == 2) or (zhang+li+wang == 1 and a+b+c == 1):表示3個人中1個人說謊或者兩個人說謊
if a == 1:
zhang = '真話'
else:
zhang = '假話'
if b == 1:
li = '真話'
else:
li = '假話'
if c == 1:
wang = '真話'
else:
wang = '假話'
print('zhang說的話是:', zhang)
print('li說的話是:', li)
print('wang說的話是:', wang)

相關文章