Unit 4 Lesson 9
Functions Explore
To do: November 18
To do: November 18
The diagram to the right shows a circuit composed of three logic gates. Each gate takes two inputs and produces a single output.
For which of the following input values will the circuit have an output of true?
A. A = true, B = true, C = true, D = false
B. A = true, B = false, C = false, D = false
C. A = false, B = true, C = true, D = true
D. A = false, B = false, C = true, D = true
To do: November 18
The diagram to the right shows a circuit composed of three logic gates. Each gate takes two inputs and produces a single output.
For which of the following input values will the circuit have an output of true?
A. A = true, B = true, C = true, D = false
B. A = true, B = false, C = false, D = false
C. A = false, B = true, C = true, D = true
D. A = false, B = false, C = true, D = true
To do: November 18
In a certain country, a person must be at least 16 years old to drive a car and must be at least 18 years old to vote. The variable age represents the age of a person as an integer. Which of the following expressions evaluates to true if the person is old enough to drive but not old enough to vote, and evaluates to false otherwise?
I. (age ≥ 16) AND (age ≤ 18)
II. (age ≥ 16) AND (NOT(age ≥ 18))
III. (age < 18) AND (NOT(age < 16))
a) I only b) II only c) III only d) II and III e) I, II and III
To do: November 18
In a certain country, a person must be at least 16 years old to drive a car and must be at least 18 years old to vote. The variable age represents the age of a person as an integer. Which of the following expressions evaluates to true if the person is old enough to drive but not old enough to vote, and evaluates to false otherwise?
I. (age ≥ 16) AND (age ≤ 18)
II. (age ≥ 16) AND (NOT(age ≥ 18))
III. (age < 18) AND (NOT(age < 16))
a) I only b) II only c) III only d) II and III e) I, II and III
Go over homework
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
Unit 4 Lesson 9 Bubble 4
Unit 4 Lesson 9 - Activity
Unit 4 Lesson 9 Bubble 4
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
5th period: Quiz is tomorrow (Friday)
Conditionals and Booleans Quiz
8 MC questions