练习 35 分支和函数
ex35.py
练习 35 会话
You are in a dark room.
There is a door to your right and left. Which one do you take?
There is a bear here.
The bear has a bunch of honey.
The fat bear is in front of another door. How are you going to move the bear?
> taunt bear
> open door
> 1000
You greedy bastard! Good job!
- 画一个这个游戏的流程图,并指出它是如何运转的。
- 修正你的错误,包括拼写和语法错误。
- 为你不理解的函数写上注释。
- 为游戏增加一些功能,同时使代码更加简化。
为什么你要用 while True
? 这样可以构建一个无限循环。
为什么 input()
有时会被写成 input('> ')
? input 的参数是一个字符串,所以要在获取用户输入的内容前面加一个提示符。(ai酱注:这里 >
也可以换成想要提示用户的文字。)