Skip to content

Commit 944e1be

Browse files
committed
if
1 parent f6eaf56 commit 944e1be

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

‎120.md‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,7 @@ or,翻译为“或”运算。在A or B中,它是这么运算的:
158158
if A==True:
159159
return True
160160
else:
161-
if B==True:
162-
return True
163-
else if B==False:
164-
return False
161+
return bool(B)
165162

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

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

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

0 commit comments

Comments
 (0)