第29个python程序:if语句
2016-09-28 15:09
344 查看
[root@mysql1 pshell]# cat ex29.py
#!/usr/bin/env Python
#-*-coding:utf-8-*-
people=20
cats=30
dogs=15
if people<cats:
print "too many cats! the world is doomed!"
if people>cats:
print "not many cats! the world is saved!"
if people<dogs:
print "the world is drooled on!"
if people>dogs:
print "the world is dry!"
dogs+=5
if people>=dogs:
print "people are grater than or equal to dogs."
if people<=dogs:
print "people are less than or equal to dogs."
if people==dogs:
print "people are logs."
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]# python ex29.py
too many cats! the world is doomed!
the world is dry!
people are grater than or equal to dogs.
people are less than or equal to dogs.
people are logs.
#!/usr/bin/env Python
#-*-coding:utf-8-*-
people=20
cats=30
dogs=15
if people<cats:
print "too many cats! the world is doomed!"
if people>cats:
print "not many cats! the world is saved!"
if people<dogs:
print "the world is drooled on!"
if people>dogs:
print "the world is dry!"
dogs+=5
if people>=dogs:
print "people are grater than or equal to dogs."
if people<=dogs:
print "people are less than or equal to dogs."
if people==dogs:
print "people are logs."
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]# python ex29.py
too many cats! the world is doomed!
the world is dry!
people are grater than or equal to dogs.
people are less than or equal to dogs.
people are logs.
相关文章推荐
- 在pycharm中编辑Python程序 循环、IF语句报错的原因(格式问题)
- Python入门的36个例子——08 If —— 分叉语句
- Python-if语句
- Python中如何避免使用多个分支语句(多个if和else)——函数字典(Function Map)简介
- Python中if-else语句的多种写法
- python if语句
- 如何改善if语句以简化程序结构
- Python学习笔记(九):if、while、for语句
- 程序的流程控制----if语句
- Python的控制语句,(if,while,for)之if
- Python学习入门基础教程(learning Python)--3.2 if-else分支语句
- Python简单IF,WHILE语句
- Python-if-elif-else语句
- Python-if-elif-else语句
- Python学习--控制语句:if, while, for, break, continue
- Python学习笔记四:if语句
- Python-if-elif-else语句
- python 学习笔记 if语句(10)
- CH02_IF语句示例程序
- Python学习入门基础教程(learning Python)--3.1Python的if分支语句