Python学习入门基础教程(learning Python)--3.3.1 Python下的布尔表达式
2013-08-28 15:46
861 查看
[python]view plaincopyprint?def if_check():
if1:
print("1")
if0:
print("0")
if -100:
print("-100")
if100:
print("100")
ifTrue:
print("true")
ifFalse:
print("false")
def main():
if_check()
main()
<PRE style=""display: none'" class='\"python\"' name='\"code\"'>def if_check():
if 1:
print(\"1\")
if 0:
print(\"0\")
if -100:
print(\"-100\")
if 100:
print(\"100\")
if True:
print(\"true\")
if False:
print(\"false\")
def main():
if_check()
main() 运行结果如下所示。
可以看出只有布尔表达式是0和False这两条if语句没有被执行,而布尔表达式为1 -100 100 True的if语句其下的打印语句都执行了。
if1:
print("1")
if0:
print("0")
if -100:
print("-100")
if100:
print("100")
ifTrue:
print("true")
ifFalse:
print("false")
def main():
if_check()
main()
<PRE style=""display: none'" class='\"python\"' name='\"code\"'>def if_check():
if 1:
print(\"1\")
if 0:
print(\"0\")
if -100:
print(\"-100\")
if 100:
print(\"100\")
if True:
print(\"true\")
if False:
print(\"false\")
def main():
if_check()
main() 运行结果如下所示。
可以看出只有布尔表达式是0和False这两条if语句没有被执行,而布尔表达式为1 -100 100 True的if语句其下的打印语句都执行了。
相关文章推荐
- Python学习入门基础教程(learning Python)--3.3.1 Python下的布尔表达式
- Python学习入门基础教程(learning Python)--3.3.1 Python下的布尔表达式
- Python学习入门基础教程(learning Python)--3.3.1 Python下的布尔表达式
- Python学习入门基础教程(learning Python)--3.3.1 Python下的布尔表达式
- Python学习入门基础教程(learning Python)--3.3.3 Python逻辑关系表达式
- Python学习入门基础教程(learning Python)--2.2.2 Python全局和局部变量 .
- Python学习入门基础教程(learning Python)--3.2 if-else分支语句 .
- Python学习入门基础教程(learning Python)--3.3.4 Python的if-elif-else语句
- Python学习入门基础教程(learning Python)--2.2.1 Python下的变量解析
- Python学习入门基础教程(learning Python)--1.2.3 Python格式化输出百分比
- Python学习入门基础教程(learning Python)--5.6 Python读文件操作高级
- Python学习入门基础教程(learning Python)--4 Python的循环结构
- Python学习入门基础教程(learning Python)--2.2 Python下的变量基础
- Python学习入门基础教程(learning Python)--5.1 Python下文件处理基本过程
- Python学习入门基础教程(learning Python)--2.3.3Python函数型参详解
- Python学习入门基础教程(learning Python)--6.4 Python的list与函数
- Python学习入门基础教程(learning Python)--3.3 分支语句的条件表达式详解 .
- Python学习入门基础教程(learning Python)--1.2.4 Python格式化输出科学计数 .
- Python学习入门基础教程(learning Python)--2.3.1 Python传参函数设计
- Python学习入门基础教程(learning Python)--3.3.3 Python逻辑关系表达式