Coding + Physics: Lesson Plan
Coding + Physics: Lesson Plan
CODING + PHYSICS
AGES:
K-5
STUDENT ENGAGEMENT:
15-30 students per facilitator, no prior skill necessary.
3-PS2-2
4-PS3-3
Ask questions and predict outcomes about the changes in energy that occur
when objects collide.
5-PS2-1
3-5-ETS1-3
Plan and carry out fair tests in which variables are controlled and failure points
are considered to identify aspects of a model or prototype that can be
improved
Kick off your Hour of Code by inspiring students and discussing how computer science
impacts every part of our lives and is revolutionizing the study of biology.
Show
2. (optional) Have them set up an account if they want to save their progress and show
their parents their work later! An email address is required to do this.
3. Press the star-shaped New App button, enter the app number (XXXX) and click "Go".
When your students have a working 2nd app (Trampoline) ask questions or have them discuss
with a partner / neighbor:
What causes you to fall when you jump up?
Possible answer: Gravity! The Earths massive size pulls us towards its center
Why does a trampoline make you jump higher?
Possible answer: The trampoline is bouncy and works like a spring when we
jump on it. When we fall down, it stretches the trampoline down but the elastic
material wants to reshape so it pushes us up again as it re-shapes.
As you walk around the room, you can help students answer the following questions about
their code:
How could you make the jumper fall faster? [Hint: look at line 8 and change the 2 into
a bigger number]
How could you change the code so you can move the trampoline up and down not just
side to side? How does this change your app? Do you find any problems when this is
changed?
Hint: change to toy.move(x,y)
[OPTIONAL DISCUSSION OF BIGGER PICTURE: Gravity, Conversion of energy during collisions]
Quick Trampoline
1. fill('backyard')
2. toy = stamp('trampoline',384,900,200)
3.
4. function drag() {
5. toy.move(x,900)
6. }
Trampoline
App Number: 4225 simplified
1. fill('backyard')
2. toy = stamp('trampoline',384,900,200)
3. kid = stamp('jumper',300)
4. fall = 0
5.
6. function loop() {
7. kid.move(NORTH,fall)
8. fall = fall - 2
9. if (kid.hits(toy)) {
10.
fall = Math.abs(fall)
11.
kid.rotate(random(360),1000)
12. }
13.}
14.
15.function drag() {
16. toy.move(x,900)
17.}
8. across = 0
9. fall = 0
10.gravity = 4
11.power = 0
12.
13.function loop() {
14. bird.move(RIGHT,across)
15. bird.move(DOWN,fall)
16. fall = fall + gravity
17. if (bird.hits(robot)) {
18.
robot.explode()
19.
sound('hurt')
20. }
21.}
22.
23.function touching() {
24. power = power + 1
25. bird.move(180,770)
26. output.change(power)
27.}
28.
29.function untouch() {
30. bird.unhide()
31. sound('bloop',power*2)
32. across = power
33. fall = power * -2
34. power = 0
35.}