Lesson Overview
Using conditionals, students will write functions and programs that change their behavior based on logical evaluation of input values.
Lesson Objectives
Students will:
Use Boolean operators to compare values.
Apply Boolean logic, such as AND, OR, and NOT, to compose complex Boolean comparisons.
Write conditional statements that evaluate differently based on their input values.
Anchor Standard
Common Core Math Standards
 6.NS.8: Solve realworld and mathematical problems by graphing points in all four quadrants of the coordinate plane. Include use of coordinates and absolute value to find distances between points with the same first coordinate or the same second coordinate.
Additional standards alignment can be found at the end of this lesson
Teaching Guide
Materials, Resources, and Prep
For the Student
 Cost Design Recipe (in the student workbook)
 Updateplayer Design Recipe (in the student workbook)
 Key Code Reference (in the student workbook)
Getting Started
1) Introduction
Remind students of the game they played in the last stage. What were some of the tricky elements of constructing a good conditional statement?
 Order matters (the first condition in the list to return true wins).
 Write clear and explicit conditions.
 Use the else clause as a catchall for conditions that you don't expect or can't write explicit conditions for.
 All conditionals must have at least one condition and an else statement, you can add or remove further conditions using the blue buttons.
At the end of this stage, students will return to their Big Game to complete the updateplayer function. This function contains a conditional that will check which key was pressed (using key codes), and move the player up or down accordingly. We've provided a key code reference for students in case they wish to use keys other than the default up (38) and down (40) arrows.
Lesson Tip
Be sure to check students’ Contracts and Examples during this exercise, especially when it’s time for them to circle and label what changes between examples. This is the crucial step in the Design Recipe where they should discover the need for cond
.
Activity: Conditionals
2) Online Puzzles
Head to CS in Algebra stage 18 in Code Studio to get started programming.
Extension Activities
3) Improving Luigi's Pizza
The final puzzle in the Luigi's Pizza sequence is a Free Play puzzle that allows for students to extend the program in a number of different ways. While some of the potential extensions seem simple, they can be deceptively challenging to get working. Allow students to explore extensions individually, or choose one to work through as a whole class.

Coupon Code: Write a function
coupon
that takes in a topping and a coupon code and returns the price of a pizza with that topping, with %40 off is the code is correct. 
Multiple Toppings: Write a function
twotoppings
that takes in two toppings and returns the price of a pizza with those toppings. 
Picture Menu: Write a function
pizzapic
that takes in a topping and returns a simple image representing a pizza with that topping.
3) Update Player
The updateplayer
function is one of the most extensible in the Big Game. Here's a brief list of potential challenge extensions to give students:
 Warping: instead of having the player’s ycoordinate change by adding or subtracting, replace it with a Number to have the player suddenly appear at that location. (For example, hitting the "c" key causes the player to warp back to the center of the screen, at y=200.)
 Boundarydetection: Keep the player on screen by changing the condition for moving up so that the player only moves up if the up ke was pressed AND playery is below the top border. Likewise, change the condition for down to also check that playery is above the bottom.
 Wrapping: Add a condition (before any of the keys) that checks to see if the player’s ycoordinate is above the screen. If it is, have the player warp to the bottom. Add another condition so that the player warps back up to the top of the screen if it moves below the bottom.
 Dissapear/Reappear: Have the player hide when the "h" key is pressed, only to reappear when it is pressed again!
Standards Alignment
Common Core Math Standards
 5.OA.1  Use parentheses, brackets, or braces in numerical expressions, and evaluate expressions with these symbols.
 5.OA.2  Write simple expressions that record calculations with numbers, and interpret numerical expressions without evaluating them. For example, express the calculation “add 8 and 7, then multiply by 2” as 2 × (8 + 7). Recognize that 3 × (18932 + 921) is three times as large as 18932 + 921, without having to calculate the indicated sum or product.
 6.NS.8  Solve realworld and mathematical problems by graphing points in all four quadrants of the coordinate plane. Include use of coordinates and absolute value to find distances between points with the same first coordinate or the same second coordinate.
 6.EE.9  Use variables to represent two quantities in a realworld problem that change in relationship to one another; write an equation to express one quantity, thought of as the dependent variable, in terms of the other quantity, thought of as the independent variable. Analyze the relationship between the dependent and independent variables using graphs and tables, and relate these to the equation. For example, in a problem involving motion at constant speed, list and graph ordered pairs of distances and times, and write the equation d = 65t to represent the relationship between distance and time.
 7.EE.4  Use variables to represent quantities in a realworld or mathematical problem, and construct simple equations and inequalities to solve problems by reasoning about the quantities.
 8.F.1  Understand that a function is a rule that assigns to each input exactly one output. The graph of a function is the set of ordered pairs consisting of an input and the corresponding output.1
 8.F.2  Compare properties of two functions each represented in a different way (algebraically, graphically, numerically in tables, or by verbal descriptions). For example, given a linear function represented by a table of values and a linear function represented by an algebraic expression, determine which function has the greater rate of change.
Common Core Math Practices
 MP.1  Make sense of problems and persevere in solving them.
 MP.2  Reason abstractly and quantitatively.
 MP.3  Construct viable arguments and critique the reasoning of others.
 MP.4  Model with mathematics.
 MP.5  Use appropriate tools strategically.
 MP.6  Attend to precision.
 MP.7  Look for and make use of structure.
 MP.8  Look for and express regularity in repeated reasoning.