Unit 4
Turtle Programming part 3
To do: November 17- Warm-up #1
a <- true
b <- false
c <- true
b <- ( NOT b ) OR b AND c
c <- b AND a
DISPLAY ( a )
DISPLAY ( b )
DISPLAY ( c )
To do: November 17 - Warm-up #2
a <- true
b <- false
c <- true
a <- NOT ( a OR b ) AND c
b <- c AND a
DISPLAY ( a )
DISPLAY ( b )
DISPLAY ( c )
Revisit 3x3 Square Grid
Take out your IN.
Now that you can create functions, you will draw the 3x3 square grid using functions.
Plan with your partner which functions you will create.
One of the functions should be drawSquareGrid() which will be called on once.
Intro to Top-Down Design
Example of Top-Down Approach
Code.org '19-20 Unit 3 Lesson 6 bubble 3
Complete Bubble 3 together. Write out the names of the functions you created in your IN.
One of the functions should be drawSquareGrid() which will be called on once.
Code.org '19-20 Unit 3 Lesson 6 bubble 3
Complete Bubble 3 together. Write out the names of the functions you created in your IN.
When you are done, complete bubble 2.
Go over homework
Boolean expressions / Conditional statements quiz on Thursday
Unit 4 Lesson 9 - Warm Up
Prompt
In the Hub, click on the link to the song lyrics of "Wake me up when it's all over" using 2 different styles.
Unit 4 Lesson 9 - Warm Up
Prompt
3. What are the benefits of writing a song in Style 2?
Style 2 is an example of an abstraction.
An abstraction is the process of reducing complexity by focusing on the main idea. By hiding details irrelevant to the question at hand and bringing together related and useful
details, abstraction reduces complexity and allows one to focus on the idea.
Unit 4 Lesson 9 - Activity
What is a function?
A function is a named group of programming instructions that can be called upon from different parts of the program but only need to be defined once.
Functions are reusable abstractions that reduce the complexity of writing and maintaining programs.
Function: a named group of programming instructions. Also referred to as a “procedure”.
Function Call: a command that executes the code within a function definition
Unit 4 Lesson 9 - Wrap Up
Unit 4 Lesson 9 - Activity
Functions Explore (individually)
Do This:
Unit 4 Lesson 9 - Activity
Bubble 4
Unit 4 Lesson 9 - Activity
Bubble 5
Unit 4 Lesson 9 - Wrap Up
The updateScreen() Pattern
Code (Block) | Code (Text) |
| var count = 0; updateScreen(); onEvent(“upButton”, “click”, function(){ count = count + 1; updateScreen(); }); onEvent(“downButton”, “click”, function(){ count = count - 1; updateScreen(); }); function updateScreen(){ setText(“countLabel”, count); if(count > 20){ setProperty(“countLabel”, “text-color”, “green”); } } |
Homework
Tomorrow, we'll complete Lesson 9 together.