[問題] 想請問此程式中某兩行的意思已刪文

看板Python作者 (Frank)時間6年前 (2019/04/28 21:16), 編輯推噓2(426)
留言12則, 6人參與, 6年前最新討論串1/1
看不懂此程式此兩行的意思 caveNumber = chooseCave() checkCave(caveNumber) 能否請高手解釋一下呢?? 謝謝 原程式如下 import random import time def displayIntro(): print('Your are in a land full of dragons. In front of you,') print('you see two caves. In one cave, the dragon is friendly') print('and will share his treasure with you. The other dragon') print('is greedy and hungry, and wil eat you on sight.') print() def chooseCave(): cave = '' while cave != '1' and cave != '2': print('Which cave will you go into? (1 or 2)') cave = input() return cave def checkCave(chosenCave): print('You approach the cave...') time.sleep(2) print('It is dark and spooky...') time.sleep(2) print('A large dragon jumps out in front of you! He opens his jaws and ...') print() time.sleep(2) friendlyCave = random.randint(1,2) if chosenCave == str(friendlyCave): print('Gives you his treasure!') else: print('Gobbles you down in one bite!') playAgain = 'yes' while playAgain == 'yes' or playAgain == 'y': displayIntro() caveNumber = chooseCave() checkCave(caveNumber) playAgain = input('Do you want to play again? (yes or no)\n') -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.140.20.39 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1556457375.A.65B.html

04/28 21:22, 6年前 , 1F
你是不懂function call?
04/28 21:22, 1F

04/28 21:50, 6年前 , 2F
你之前問的問題和現在問的(包括剛剛刪掉的),要認真走
04/28 21:50, 2F

04/28 21:50, 6年前 , 3F
一次基本觀念
04/28 21:50, 3F

04/28 21:51, 6年前 , 4F
w3cschool或自強學堂,用三小時跟著上面資訊走一次,就可
04/28 21:51, 4F

04/28 21:51, 6年前 , 5F
以建立
04/28 21:51, 5F

04/28 21:53, 6年前 , 6F
04/28 21:53, 6F

04/28 21:55, 6年前 , 7F

04/28 21:55, 6年前 , 8F
on3-tutorial.html
04/28 21:55, 8F

04/28 22:25, 6年前 , 9F
而且問完都刪文,很怕人家看到是不是
04/28 22:25, 9F

04/29 01:40, 6年前 , 10F
有問完刪文這種記錄我就覺得不想回了,欠缺社群互助精神
04/29 01:40, 10F

04/29 01:55, 6年前 , 11F
刪爽沒
04/29 01:55, 11F

04/29 11:09, 6年前 , 12F
他怕被老師看到~ 這是Invent with Python的例子啊!
04/29 11:09, 12F
文章代碼(AID): #1SnQUVPR (Python)
文章代碼(AID): #1SnQUVPR (Python)