Skip to content

Commit

Permalink
if
Browse files Browse the repository at this point in the history
  • Loading branch information
qiwsir committed Jan 29, 2016
1 parent f6eaf56 commit 944e1be
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions 120.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ or,翻译为“或”运算。在A or B中,它是这么运算的:
if A==True:
return True
else:
if B==True:
return True
else if B==False:
return False
return bool(B)

上面这段算是伪代码啦。所谓伪代码,就是不是真正的代码,无法运行。但是,伪代码也有用途,就是能够以类似代码的方式表达一种计算过程。

Expand All @@ -170,10 +167,7 @@ or,翻译为“或”运算。在A or B中,它是这么运算的:
if A==True: #如果A的值是True
return True #返回True,表达式最终结果是True
else: #否则,也就是A的值不是True
if B==True: #看B的值,然后就返回B的值做为最终结果。
return True
else if B==False:
return False
return bool(B) #看B的值,然后就返回B的值做为最终结果。

举例,根据上面的运算过程,分析一下下面的例子,是不是与运算结果一致?

Expand Down

0 comments on commit 944e1be

Please sign in to comment.