您的位置:首页 > 编程语言 > Python开发

python的条件分支语句(if)

2014-10-16 11:33 387 查看
Python的条件分支语句语法JAVA和C略有不同使用 if 条件语句:的形式:

<span style="font-size:14px;">count = int(raw_input("please input your math record:"))
print count
if count > 90:
print 'a'
elif count > 80:
print 'b'
elif count > 70:
print 'c'
elif count > 60:
print 'd'
else:
print 'e'
print 'end'

sex = raw_input("please input your sex:")
if sex == 'mail':
print 'gentleman!'
else:
print 'lady!'

print 'end'</span>


条件判断表达式: 布尔表达式 非0即真。

if 1:
print 'true'
else:
print 'false'
if 109:
print 'true'
else:
print 'false'

if 'Hello':
print 'true'
else:
print 'false'
结果全是true
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python