Python的条件分支语句语法JAVA和C略有不同使用 if 条件语句:的形式:
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'
条件判断表达式: 布尔表达式 非0即真。
if 1:
print 'true'
else:
print 'false'
if 109:
print 'true'
else:
print 'false'
if 'Hello':
print 'true'
else:
print 'false'
结果全是true