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

第30个python程序:else和if

2016-09-29 17:01 417 查看
[root@mysql1 pshell]# cat ex30.py    

#!/usr/bin/env Python

#-*-coding:utf-8-*-

people=30

cars=40

buses=15

if cars>people:

  print "we should take the cars."

elif cars<people:

  print "we should not take the cars."

else:

  print "we can't decide."

if buses>cars:

  print "that's too many buses."

elif buses<cars:

  print "maybe we could take the buses."

else:

  print "we still can't decide."

if people>buses:

  print "alright,let's just take the buses."

else:

  print "fine,let's stay home then."

[root@mysql1 pshell]# 

[root@mysql1 pshell]# 

[root@mysql1 pshell]# 

[root@mysql1 pshell]# python ex30.py 

we should take the cars.

maybe we could take the buses.

alright,let's just take the buses.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python