python学习(​条件控制分支语句if)

#!/usr/bin/python
count =int(raw_input("Plz input your math record:"))
print count
if count >= 90:
   print 'a'
else:
   if count >=80:
       print 'b'
   else:
        if count >=70:
          print 'c'
        else:
           if count >=60:
             print 'd'
           else:
              print 'no pass'
print 'End'
sex =raw_input("Plz input your sex:")
print 'sex', sex
if sex == 'male':
        print 'Gentlenman!'
else:
        print 'Lady!'


条件控制分支语句if

判断条件

布尔表达式 非0既真


[root@ceshi ~]# python ceshi.py
True
False
[root@ceshi ~]# vim ceshi.py
#!/usr/bin/python
if True:
  print 'True'
else:
  print 'False'
if 0:
  print 'True!'
else:
  print 'False'


[root@ceshi ~]# cat ceshi.py
#!/usr/bin/python
if True:
  print '1True'
else:
  print '1False'
if 0:
  print '2True!'
else:
  print '2False'
if 1:
  print '3True!'
else:
  print '3False'
[root@ceshi ~]# python ceshi.py
1True
2False
3True!


条件判断:关系表达式

->

-<

-==

- !=

->=

-<=

record =int(raw_input('plz input your record '))
print record,
if record >= 90:
  print "Excellent!"
else:
  print " Good"
sex = raw_input('plz input your sex ')
if sex == 'male':
 print 'Man'
else:
 print 'Woman'


逻辑表达式

-and

-or

-not

record =int(raw_input('plz input your record '))
print record,
if record >= 90:
  print "Excellent!"
else:
  print " Good"
sex = raw_input('plz input your sex ')
if sex == 'male'or sex == 'm'  or sex =='M' or sex =='man' or sex =='Man':
 print 'Man'
else:
 print 'Woman'


plz input your record 89

89  Good

plz input your sex m

Man


你可能感兴趣的:(python,表达式,record,count,布尔)