LESSON 11

GOAL: Students will be able to…

  1. Explain the purpose of an If/Else statement
  2. Create If/Else statements to solve new types of problems
  3. Identify when an If/Else statement is appropriate to be used

VOCAB: 

  1. If Statement–An if statement lets you ask a question to the program and only run code if the answer is true.
  2. If Else Statement–Control structure that lets us do either one section of code or another depending on a test.
  3. Control Structure–A control structure lets us change the flow of the code.

DO THE FOLLOWING IN ORDER:

  1. REVIEW:
    1. Do 1.10.2 If Statements Quiz
    2. Complete the To If, Or Not To If handout individually or in pairs.
  2. Do Now: Your best friend and you agree to go to the theater to see the latest action hero movie. When you arrive however, you are saddened to find out that it has sold out. What activity might you do instead? If that activity can’t be done, what else might you and your friend do to have a fun evening?
    1. Record them as an if/else statement with correct syntax.
    2. What did you notice about what you wrote and how the code is executed?
    3. What might your default command be (goHome(), goToBed(), etc)?
  3. Watch 1.11.1 If/Else Statements
  4. Explore  1.11.3 If/Else Statements and 1.11.4 One Ball in Each Spot exercises.
  5. Do & show me 1.11.5 Right Side Up & 1.11.6 Right vs. Left Square individually or in pairs.
  6. FYI: CodeHS Online Textbook–use this as a resource
  7. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
  1. Explain the difference between an if statement and an if/else statement.
  2. Give an example of a problem that Karel would need an if statement to solve
  3. Give an example of a problem that Karel would need an if/else statement to solve
  4. Why are if/else statements useful?
  5. Write out real life scenarios that would involve if/else statements. For example:
if(favoriteSongOnPandora()){
    dance();
} else {
    doHomework();
}

Leave a comment

Your email address will not be published. Required fields are marked *