最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

習(xí)題 29: 如果(if)?

下面是你要寫(xiě)的作業(yè),這段向你介紹了“if語(yǔ)句”。把這段輸入進(jìn)去,讓它能正確執(zhí)行。然后我們看看你是否有所收獲。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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."

你應(yīng)該看到的結(jié)果?

$ python ex29.py 
Too many cats! The world is doomed!
The world is dry!
People are greater than or equal to dogs.
People are less than or equal to dogs.
People are dogs.
$

加分習(xí)題?

猜猜“if語(yǔ)句”是什么,它有什么用處。在做下一道習(xí)題前,試著用自己的話回答下面的問(wèn)題:

  1. 你認(rèn)為 if 對(duì)于它下一行的代碼做了什么?
  2. 為什么 if 語(yǔ)句的下一行需要 4 個(gè)空格的縮進(jìn)?
  3. 如果不縮進(jìn),會(huì)發(fā)生什么事情?
  4. 把習(xí)題 27 中的其它布爾表達(dá)式放到``if語(yǔ)句``中會(huì)不會(huì)也可以運(yùn)行呢?試一下。
  5. 如果把變量 people, cats, 和 dogs 的初始值改掉,會(huì)發(fā)生什么事情?

Project Versions

Table Of Contents

Previous topic

習(xí)題 28: 布爾表達(dá)式練習(xí)

Next topic

習(xí)題 30: Else 和 If

This Page

康乐县| 榆林市| 策勒县| 临泉县| 甘肃省| 大姚县| 木兰县| 赫章县| 宜阳县| 泗洪县| 成都市| 通辽市| 余江县| 噶尔县| 清河县| 姜堰市| 稻城县| 吐鲁番市| 竹溪县| 浮山县| 清丰县| 图木舒克市| 邮箱| 松江区| 新昌县| 衢州市| 交城县| 鲜城| 成安县| 时尚| 金门县| 长泰县| 海盐县| 莫力| 花莲市| 齐齐哈尔市| 巴塘县| 青浦区| 荥经县| 文昌市| 开封市|