簡體   English   中英

如何為變量賦值以使表達式為假?

[英]How can I give a truth-value assignment for variables in order for an expression to be false?

給定一組 Boolean 條件 A、B、C 和 D。 給出 A、B、C 和 D 的真值賦值,使表達式 ̅∨ � ∨ ̅∨ � 被評估為假。

我無法理解“給出真值賦值”是什么意思。

我在 Python 中試過這個代碼:

if a != a or b or c != c or d:
       print("True")
   else:
      print ("False")
Output
 False

a!=a總是假的,因為一個陳述不能同時是TrueFalse 改用(not a)

您的示例應如下所示:

if not a or b or not c or d:
       print("True")
   else:
      print ("False")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM