Download presentation
1
Introduction to Programming: Module 1 Blockly
(Lois Delcambre)
2
Part 1 – blockly
3
What is a program? A step-by-step set of instructions
4
an program – for a person
allrecipes.com Just flash this long enough for people to realize that this is a recipe
5
A program for a pianist Same thing – just flash it
6
Same thing – just flash it
7
You need to know how to do the task, step by step, before you can write a program to perform that task! Imagine trying to write the instructions for tying a Windsor knot – if you don’t know how to do it.
8
Plan Blockly a programming language used at code.org - to teach beginners how to program Python a programming language used by Google and other companies. Also used for teaching. We’ll use the turtle module
9
Plan for today introduction to puzzles; blocks executed one after the other; repeat block (with blocks inside) blocks that check conditions repeat while, if, if/else defining new blocks/commands by defining functions
10
a puzzle You need to write a program so that the bee can: get all the nectar (from flowers) & make all the honey (in honeycombs) I think you can go very quickly through the next dozen slides or so.
11
the bee
12
dark green squares - where the bee can move
13
The rest of the puzzle board can be ignored.
The bee can’t go there.
14
a flower where a bee can get nectar
small number tells you how many times the bee can sip nectar here
15
a honeycomb where a bee can make honey
small number tells you how many times the bee can deposit honey here
16
bee blocks/commands forward (one square) turn left/right
get nectar from a flower make honey in a honeycomb
17
One program that works …
18
Another program that works …
19
A program that doesn’t work … Why not?
20
Screen layout – for blockly
21
the puzzle
22
the description of the puzzle
23
the commands/blocks you can use
24
your program
25
drag and click commands to attach them to other commands
26
Pull them apart to rearrange your commands (note this program has an error)
27
Pull them apart again
28
drag and click in a new block
29
fill in how many times you want to repeat
30
drag and click command(s) into repeat block
31
push this button to run your program
32
Demo at code.org Go to the code.org website
Click on “Elementary School” under “Educators” – the blue box second from the left Click on “Curriculum Overview” Click on Course 3
33
go to Course 3
34
Course 3, Lesson 13, Puzzle 1: bee nested loops
35
Course 3, Lesson 13, Puzzle 1: bee nested loops Modify/complete this program to solve the puzzle
36
More Class Activity Write two different programs for each
Course 3, Lesson 13, Puzzle 2 (skip the video) Course 3, Lesson 13, Puzzle 3 Also … try to make mistakes, run the puzzle before you complete it, move outside of the dark green area, try to make honey, etc. I can imagine that you won’t do this for the teacher workshop.
37
Plan for today introduction to puzzles; blocks executed one after the other; repeat block (with blocks inside) blocks that check conditions repeat while, if, if/else defining new blocks/commands by defining functions
38
take the Zombie to the sunflower; avoid the chomper
Could you write the program? zombie chomper
39
Some commands can check conditions
A condition returns either True or False A condition can be checked each time a repeat until block is about to run A condition is checked once for an if command Note: in blockly, specific conditions (for the puzzle you’re working on) are built-in.
40
The beginnings of a program
Course 3, Lesson 8, Puzzle 3
41
A completed program that works
42
Maze (zombie); Course 3, Lesson 8, Puzzle 4
everyone try it
43
Class Activity to practice conditionals
Course 3: Lesson 8, Puzzle 1, 2, 3, and 8 if/else and repeat until with the zombie
44
Plan for today introduction to puzzles; blocks executed one after the other; repeat block (with blocks inside) blocks that check conditions repeat while, if, if/else defining new blocks/commands by defining functions
45
Defining new commands!!! video
Make sure this link works. It should be a video of Chris Bosh explaining how you can “define new commands” in blockly by defining functions. He makes some great basketball analogies. I want to show this to the teachers because this (to me) is probably one of the most important parts of the CS curriculum. Students need to know that through the use of functions they can make their code: more readable, more reusable, much more easy to debug/develop, and so on. So , it would be god for teachers to see this. Video is short – maybe a minute or two. I linked to the youtube version of this video; there’s a copy on the code.org site; I can find it for you if you like.
46
Note: we’ve seen functions before
This next part could be skipped – but you can also flash through it.
47
Chorus: Baa, baa black sheep, Have you any wool? Yes sir, yes sir, Three bags full. One for the master. One for the dame. And one for the little boy who lives down the lane. Chorus One to mend the jerseys, One to mend the socks. And one to mend the holes In the little girl's socks.
48
function definition Chorus: Baa, baa black sheep, Have you any wool? Yes sir, yes sir, Three bags full. One for the master. One for the dame. And one for the little boy who lives down the lane. Chorus One to mend the jerseys, One to mend the socks. And one to mend the holes In the little girl's socks. function name function invocation
49
Note: we are expected to sing the chorus
function definition Chorus: Baa, baa black sheep, Have you any wool? Yes sir, yes sir, Three bags full. One for the master. One for the dame. And one for the little boy who lives down the lane. Chorus One to mend the jerseys, One to mend the socks. And one to mend the holes In the little girl's socks. Note: we are expected to sing the chorus in the beginning, once. In a program, the function definition is NOT executed. It is only executed when we have a function invocation. function name function invocation
50
Another Example of Function Definition and Invocation (on next page)
Triple Coconut Cake Recipe
51
This recipe asks you to make other recipes (defined elsewhere)
Triple Coconut Cake Recipe More ingredients More instructions
52
Function Invocation Triple Coconut Cake Recipe More ingredients More instructions
53
Let’s see functions in blockly
The next dozen or so slides just explain how function definition appears in blockly. Teachers should get the idea of what this is – maybe by discussing it with their neighbor. They may or may not want to try using it in blockly.
54
This gray box defines a function; you can put code in the gray box
55
Here is the name of the function
56
the new function is just like any other command!
57
“get 5” command is in the program (note: this program doesn’t work)
58
Class Activity to practice using functions
Course 3, Lesson 6: Puzzles 3, 4, and 5 Show this to teachers but don’t expect them to do it. (or, don’t even show it.)
59
For practice repeat, repeat until, if, and functions
Course 3: Lesson 13 – all puzzles Course 3: Lesson 8 – all puzzles Course 3: Lesson 6 – all puzzles This doesn’t really need to be in here – but it can be; just don’t spend any time here. I may change it for 2017.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.