- 学一学28 分钟 · 数学积木、pick random、join、检查答案
- 基础任务25 分钟 · 一轮五道题
- 挑战 1–327 分钟 · 7 的乘法、一轮加法、缺了一个数
- 加分任务加分 · 玩家自己选几道题
复习:怪兽制造机 5 分钟
怪兽制造机做完了。今天又要用到里面的三样东西。
- 每个部位都是一个造型。
(costume [number v])告诉我们它穿的是哪一个。 change [color v] effect by (25)不用新造型,也能改变一个部位。go to [front v] layer把一个部位放到其他部位的上面。
快问快答
“随机怪兽”按钮帮你选了一个头。是哪块积木让程序来选的?
看答案
(pick random (1) to (6)),放进switch costume to [costume1 v] 里面。是程序选了一个数字,不是你。今天它要为数学题选数字。
今天的主题 3 分钟
((3) * (4))、((3) + (4))和((9) - (4)):Scratch 来算(pick random (1) to (10)):没人选过的数字(join (a) (join [ × ] (b))):用数字拼成的题目<(answer) = ((a) * (b))>:Scratch 检查答案
学习目标
上完这节课,你能够:
- 用绿色的数学积木算出一个数。
- 用 pick random 和 join,每次都出一道新题。
- 检查输入的答案。答错时,说出正确答案。
学一学:一道没人写过的题 28 分钟
1 · Scratch 会算数
在第 1 级,你的问答游戏只知道一个答案。那是你自己输进去的。今天,答案由 Scratch 来算。
- 点 Operators(运算)。它是绿色的那一类。
- 把
(() * ())拖到脚本区。 - 点左边的圆圈,输入 7。点右边的圆圈,输入 8。
- 点积木本身,不要点圆圈。
- 积木下面会弹出一个小气泡。上面写着 56。
((7) + (8))
((15) - (8))
((7) * (8))
这些圆圆的积木会报告一个数。所以你可以把它放进任何圆形的空格里:say 积木、set 积木,甚至另一块绿色积木。
when flag clicked
say ((7) * (8)) for (2) seconds
say ((7) + (8)) for (2) seconds
say ((15) - (8)) for (2) seconds
怎么用: 点绿旗开始。不用再按别的,看它运行完,然后点 ↺ Reset 再运行一次。
2 · 没人选过的数字
每次都是同一道题的问答游戏很无聊。让程序来选数字吧。
我们需要地方放这两个数,所以要做两个变量。在数学里,这两个数常常叫 a 和 b,所以我们就用这两个名字。
- 点 Variables(变量),再点 Make a Variable(新建变量)。
- 输入
a,保留 For all sprites(适用于所有角色),按 OK。 - 再做一次,这次是
b。 - 拖出
set [a v] to (0)。 - 从 Operators 里把
(pick random (1) to (10))放进它的圆圈里。 - 用第二块 set 积木,给 b 做一样的事。
set [a v] to (pick random (1) to (10))
set [b v] to (pick random (1) to (10))
3 · 把题目拼起来
题目有三部分:a、符号和 b。(join [apple ] [banana]) 积木只能拼两部分。所以我们把一个 join 放进另一个 join 里。
- 把一个
(join [apple ] [banana])拖到脚本区。 - 把第二个 join 拖进它右边的空格。
- 把
(a)放进第一个空格。 - 在中间的空格里,先输入一个空格,再输入 ×,再输入一个空格。
- 把
(b)放进最后一个空格。
say (join (a) (join [ × ] (b))) for (2) seconds
把这些都放进一个循环里,巫师就会自己出五道题。
when flag clicked
repeat (5)
set [a v] to (pick random (1) to (10))
set [b v] to (pick random (1) to (10))
say (join (a) (join [ × ] (b))) for (2) seconds
say (join [The answer is ] ((a) * (b))) for (2) seconds
end
怎么用: 点绿旗开始。不用再按别的,看它运行完,然后点 ↺ Reset 再运行一次。
4 · Scratch 检查答案
现在巫师不是说,而是问。你在问答秀里见过 ask [What's your name?] and wait。题目放进它白色的空格里,join 也放得进去。
要检查答案,就把 (answer) 和 ((a) * (b)) 比一比。你从来不用输入正确答案。每次都是 Scratch 自己算出来的。
when flag clicked
set [a v] to (pick random (1) to (10))
set [b v] to (pick random (1) to (10))
ask (join (a) (join [ × ] (b))) and wait
if <(answer) = ((a) * (b))> then
say [Correct!] for (2) seconds
else
say (join [Not quite. The answer is ] ((a) * (b))) for (3) seconds
end
怎么用: 点绿旗,然后在框里输入你的答案,按 Enter。
为什么一定要用 a 和 b?
为什么不把 pick random 直接放进题目里?试一试。它会悄悄地出错。
ask (join (pick random (1) to (10)) (join [ × ] (pick random (1) to (10)))) and wait
if <(answer) = ((pick random (1) to (10)) * (pick random (1) to (10)))> then
say [Correct!] for (2) seconds
end
变量会记住这个数。题目和检查读的是同一个 a 和同一个 b,所以它们总是对得上。
基础任务:一轮五道题 25 分钟
先做好一道题,试一试。然后再把它包进循环里。
第 1 步:教室
- 新建一个作品,删掉小猫。
- 选择背景 Chalkboard。
- 添加 Wizard 角色。把他拖到黑板的左边。
第 2 步:三个变量
- 做
score、a和b三个变量,都选 For all sprites。 - score 保持勾选,这样它会显示在舞台上。
- 你想的话,可以取消勾选 a 和 b。游戏照样能玩。
第 3 步:一道题
- 在巫师上,先放
when flag clicked。 - 加上两块带 pick random 的 set 积木。
- 加上里面放了 join 的 ask 积木。
- 加一个 if / else,里面放
<(answer) = ((a) * (b))>。 - 按绿旗。答对一次,再答错一次。
第 4 步:五道题
- 把帽子积木下面的所有积木包进
repeat (5)里。 - 在 repeat 上面加上
set [score v] to (0)。 - 在 if 的上半部分加上
change [score v] by (1)。
第 5 步:得分
- 在 repeat 下面加一块 say 积木。
- 用 join 里面套 join,拼出这句话。
- 把整轮玩两次。一次好好答,一次乱答。
when flag clicked
set [score v] to (0)
repeat (5)
set [a v] to (pick random (1) to (10))
set [b v] to (pick random (1) to (10))
ask (join (a) (join [ × ] (b))) and wait
if <(answer) = ((a) * (b))> then
change [score v] by (1)
say [Correct!] for (1) seconds
else
say (join [Not quite. It is ] ((a) * (b))) for (2) seconds
end
end
say (join [You scored ] (join (score) [ out of 5])) for (4) seconds
怎么用: 点绿旗,然后在框里输入你的答案,按 Enter。做五次。
我答对了,它却说“Not quite”。
看看检查的部分。它必须用 (a) 和 (b),不能用新的 pick random 积木。
每道题都一样。
你的两块 set 积木放在了 repeat 上面。把它们移到 repeat 里面,这样每一轮都会运行。
题目显示成“7×8”,中间没有空格。
join 中间的空格里,要先输入一个空格,再输入 ×,再输入一个空格。
我答错了,得分也会加。
change 积木放在了 if 的下面,不在 if 里面。把它拖进上半部分。
7 的乘法
只练一个乘法表:7 的乘法表。
- 每道题都从 7 开始。
- 另一个数从 1 到 12。
- 一共十道题,得分要说“out of 10”(满分 10)。
怎么用: 点绿旗,然后在框里输入你的答案,按 Enter。
Teacher reveal — one number stops being random
when flag clicked
set [score v] to (0)
set [a v] to (7)
repeat (10)
set [b v] to (pick random (1) to (12))
ask (join (a) (join [ × ] (b))) and wait
if <(answer) = ((a) * (b))> then
change [score v] by (1)
say [Correct!] for (1) seconds
else
say (join [Not quite. It is ] ((a) * (b))) for (2) seconds
end
end
say (join [You scored ] (join (score) [ out of 10])) for (4) seconds
Some will type 7 straight into the join and the check. That works too. Ask them which version makes the 8 times table a one-number change.
一轮加法
把你的这一轮改成加法,数字也更大。
- 两个数都在 10 到 50 之间。
- 题目显示 + 号。
- 答错时,还是会显示正确的和。
Teacher note — three places must agree
The sign lives in three places: the join in the ask, the check, and the join in the else. Most pupils change the first and forget one of the others. The game still runs, and marks every right answer wrong.
set [a v] to (pick random (10) to (50))
set [b v] to (pick random (10) to (50))
ask (join (a) (join [ + ] (b))) and wait
if <(answer) = ((a) + (b))> then
change [score v] by (1)
else
say (join [Not quite. It is ] ((a) + (b))) for (2) seconds
end
Next lesson the right answer goes into its own variable, so it lives in one place.
缺了一个数
把题目反过来。给出答案,藏起其中一个数。
- 题目像这样:“6 × ? = 42”。
- 42 是 Scratch 自己算出来的。
- 玩家输入缺了的那个数。
- 答错时,说出缺的数是多少。
怎么用: 点绿旗,然后在框里输入你的答案,按 Enter。
Teacher reveal — the check changes, not just the words
set [a v] to (pick random (2) to (10))
set [b v] to (pick random (2) to (10))
ask (join (a) (join [ × ? = ] ((a) * (b)))) and wait
if <(answer) = (b)> then
change [score v] by (1)
say [Correct!] for (1) seconds
else
say (join [The missing number was ] (b)) for (2) seconds
end
The times block moves from the check into the question. The check becomes plain (b). Starting from 2 avoids “1 × ? = 5”, which feels like a trick.
你来选几道题
在第一道题之前,问玩家想做几道题。
- 这一轮就问刚好那么多道题。
- 最后一句说“out of”这个数。
- 输入 3 能用,输入 12 也能用。
Teacher reveal
when flag clicked
ask [How many questions?] and wait
set [rounds v] to (answer)
set [score v] to (0)
repeat (rounds)
set [a v] to (pick random (1) to (10))
set [b v] to (pick random (1) to (10))
ask (join (a) (join [ × ] (b))) and wait
if <(answer) = ((a) * (b))> then
change [score v] by (1)
end
end
say (join [You scored ] (join (score) (join [ out of ] (rounds)))) for (4) seconds
A variable fits in the repeat’s hole. Many pupils do not know that until they try. The three joins at the end are the hard part — build the inside one first.
总结 4 分钟
今天,程序不再需要你帮它写题目了。
- 绿色积木
((a) + (b))、((a) - (b))和((a) * (b))负责算数。 (pick random (1) to (10))存进变量里,每次都能出一道新题。- join 里面套 join,把数字和符号拼成一道题。
<(answer) = ((a) * (b))>用题目里同样的数字来检查答案。
- 报告积木(reporter)
- 一块圆圆的积木,会给回一个数或一个词。
- 随机
- 由电脑来选。你猜不到。
- join(连接)
- 把两段文字粘成一段。
- 运算积木(operator)
- 一块绿色积木,会算数,也会比较东西。
下一课:计时 60 秒,三条命,一轮会自己结束。