[问题] 想请问此程式中某两行的意思

楼主: qzxwec789 (Frank)   2019-04-28 21:16:13
看不懂此程式此两行的意思
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')
作者: djshen (djshen)   2019-04-28 21:22:00
你是不懂function call?
作者: jiyu520 (不要鲫鱼我)   2019-04-28 21:50:00
你之前问的问题和现在问的(包括刚刚删掉的),要认真走一次基本观念w3cschool或自强学堂,用三小时跟着上面资讯走一次,就可以建立w3school https://www.w3schools.com/python/自强学堂 https://code.ziqiangxuetang.com/python3/python3-tutorial.html
作者: art1 (人,原来不是人)   2019-04-28 22:25:00
而且问完都删文,很怕人家看到是不是
作者: sma1033 (死马)   2019-04-29 01:40:00
有问完删文这种记录我就觉得不想回了,欠缺社群互助精神
作者: silverair (木栅福山雅治)   2019-04-29 01:55:00
删爽没
作者: HotDesert (热啊!)   2019-04-29 11:09:00
他怕被老师看到~ 这是Invent with Python的例子啊!

Links booklink

Contact Us: admin [ a t ] ucptt.com