- 1025
- 0
- 约 47页
- 2017-05-27 发布于河南
- 举报
南京大学张莉用python玩转数据
Multi-dimensional View of Python
Python面面观
Department of Computer Science and Technology
Department of University Basic Computer Teaching
2
用Python玩转数据
条件
Nanjing University
if 语句 3
语 法 expression expr_true_suite
if expression : 条件表达式: • expression 条 件为
expr_true_suite • 比较运算符 True时执行的代码块
• 成员运算符 • 代码块必须缩进 (通
• 逻辑运算符 常为4个空格 )
File
# Filename: ifpro.py
sd1 = 3
sd2 = 3
if sd1 == sd2:
print the squares area is:%d % (sd1*sd2)
Nanjing University
else 语句 4
语 法
File
if expression :
# Filename: elsepro.py
expr_true_suite sd1 = int(raw_input(the first side:))
else: sd2 = int(raw_input(the second side:))
if sd1 == sd2:
expr_false_suite print the squares area is:%d %(sd1*sd2)
expr_false_suite else:
print the rectangles area is:%d %(sd1*sd2)
• expression 条 件 为
False 时执行的代码
Input and Output
块
the first side:4
• 代码块必须缩进 the second side:4
• else语句不缩进
原创力文档

文档评论(0)