CodeMonkey过关学习笔记系列:31-45关
![image48.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image48.jpeg)
第 31 关挑战
变量来源于数学,是计算机语言中能储存计算结果或能表示值抽象概念。
x = 20
step x
![image49.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image49.jpeg)
第 32 关挑战
x = 15
4.times ->
turn right
step x
![image50.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image50.jpeg)
第 33 关挑战
所有的数目字 number 你都可以用 变量 variable来代替它.
n = 6
x = 10
d = 60
n.times ->
step x
turn d
![image51.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image51.jpeg)
第 34 关挑战
t = 3
x = 20
d = 120
t.times ->
step x
turn d
![image52.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image52.jpeg)
第 35 关挑战
x=15
turtle.step x
step x
turn left
step x
![image53.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image53.jpeg)
第 36 关挑战
x = 15
4.times ->
step x
step -x
turtle.step 8
x = 15
for b in bananas
step x
step -x
turtle.step 8
![image54.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image54.jpeg)
第 37 关挑战
say "xxxxxxxxx"
step 15
![image55.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image55.jpeg)
第 38 关挑战
x = 20
say x
turnTo banana
step x
![image56.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image56.jpeg)
第 39 关挑战
变量也可以用来取代你不知道的数目.
x = distanceTo turtle
say x
step x
![image57.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image57.jpeg)
第 40 关挑战
x = turtle.distanceTo banana
step 2
![image58.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image58.jpeg)
第 41 关挑战
d = turtle.distanceTo monkey
turtle.step d
turtle.step –d
turtle.turn right
turtle.step d
![image59.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image59.jpeg)
第 42 关挑战
turnTo banana
step distanceTo banana
![image60.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image60.jpeg)
第 43 关挑战
turnTo bridge
step distanceTo bridge
turnTo banana
step distanceTo banana
![image61.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image61.jpeg)
第 44 关挑战
别让老鼠把宝贵的香蕉给偷走了 !
say "Let's go!“
turnTo banana
step distanceTo banana
![image62.jpeg](https://raw.githubusercontent.com/mageSFC/myblog/master/codemonkey/CodingAdventure_StoryMode/image62.jpeg)
第 45 关挑战
say "Hello world!“
turnTo bridge
step distanceTo bridge
turnTo banana
step distanceTo banana