Lesson 4.6 Conditionals Investigate
Sept 23(A-day) and Sept 26(B-day)
Sept 23(A-day) and Sept 26(B-day)
Code.org Assignment
Wrap Up Check your understanding
when: means there is an onEvent to respond to user input. The app does something "when" the user clicks.
if: means there is a conditional statement that decides what pieces of code to run. The app does something "if" a boolean expression evaluates to true.
mod operator %: takes two numbers, processes them, and retuns a value. EASY WAY TO UNDERSTAND - when dividing the numbers, the mod is the remaining number
Example: 5 mod 3 evaluates to 2
5 % 3 evalutates to 2
In this lesson students work with partners to investigate three versions of the "Lemon Squeeze" app to understand how boolean expressions and conditional statements allow programs to make decisions. In each guided investigation students first watch a short video on a concept, then use a working app to predict how new features work, then investigate the code to see how those features are implemented, and finally modify the code to add expanded features. To conclude the lesson, students review and discuss common programming patterns with conditionals.
After building a conceptual model for boolean expressions and conditional statements in the previous lesson, this lesson allows students to see how they are actually implemented in code. This lesson also introduces common programming patterns when using variables. Students will have some opportunities to modify working code in this lesson, but the most significant practice with conditional statements and boolean expressions will come in the following lesson.
CSP Conceptual Framework
AAP-2 - The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.
AAP-2.H - For selection: a. Represent using conditional statements. b. Determine the result of conditional statements.
AAP-2.I - For nested selection: a. Represent using nested conditional statements. b. Determine the result of nested conditional statements.
AAP-2.I.1 - Nested conditional statements, or “else if” statements, consist of conditional statements within conditional statements.
CSTA K-12 Computer Science Standards (2017)
AP - Algorithms & Programming
2-AP-10 - Use flowcharts and/or pseudocode to address complex problems as algorithms.
2-AP-12 - Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.
3B-AP-23 - Evaluate key qualities of a program through a process such as a code review.