发布时间:2017-11-15 14:41:25编辑:Run阅读(5801)
练习代码如下
# coding: utf-8
__author__ = 'www.py3study.com'
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 greater than or equal to dogs.")
if people <= dogs:
print("People are less than or equal to dogs.")
if people == dogs:
print("People are dogs.")
应该看到的结果
常见问题
+=是什么意思?
x += 1 和 x = x + 1一样,只是+=这种写法更省时间
上一篇: 习题25:布尔表达式练习
下一篇: 习题27:if和else
47604
45983
36909
34467
29079
25713
24565
19714
19245
17756
5564°
6155°
5690°
5737°
6703°
5482°
5484°
5988°
5965°
7295°