3.4 Reactions

Students are introduced to "If-Else" command in a fun reaction game. When the mouse pointer touches a sprite, the sprite reacts!
Sprite reactions range from changing color to speech. Students continually test if mouse pointer is touching sprite, when condition is True, a reaction happens!

OBJECTIVES:



OBJECTIVES: By the end of this lesson, students will:

    • identify an If-Else conditional statement

    • understand how a script branches through If-Else statement, choosing one path or another.

    • recognize reasons to continually test a condition.

TEACHER RESOURCES:

Standards

    • CSTA 2-AP-12: Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.

CSTA

DO NOW:

Do Now Digital Citizenship (5 minutes)

  1. Watch Copyright and Fair Use (2:45)

    1. Discuss:

      • What is copyright law?

      • How can you use something from the internet that has a copyright?

      • How is fair use different from copyright law?

Teacher Guidance

    • Copyright law protects your control over the creative work you make, requiring people to get your permission before they copy, rework, or share your work.

    • You can use something with a copyright if you check who owns it, get their permission to use it, give credit to the creator, buy it if necessary, and use it responsibly.

    • Fair use is using someone’s work without permission as long as it is for schoolwork & education, news reporting, criticizing or commenting, and comedy or parody. Under fair use, you can only use a small piece of the work, you must add new meaning to it, you must rework it and use it in a totally different way, and you cannot make money off your creation.

Mini-Lesson (5-10 minutes)

Mini-Lesson (3-5 minutes)

Branching:

The concept of branching code is fundamental to programming. If an event happens, do one thing. If a different event happens do another thing.

In today's lesson, the students will use an If-Else statement.

eg. IF it is snowing THEN wear boots ELSE wear shoes.

The ELSE portion makes sure that a different action is performed. Without the ELSE action, your students might be barefoot!

Code can branch down different paths:

If a condition is True,

one set of commands are processed.

If condition is Not True,

a different set of commands are processed

Screen Shot 2017-10-05 at 11.31.47 AM.png
If Then Els.jpg

Project (20-30 minutes)

Today's project is fun. The student page should be sufficient to let students work at their own pace. Students should be creative, focus on their sprites reactions and use the If-Else in a meaningful context. Students should share and showcase their work with others.

This lesson is more about exposure to the If-Else concept than about mastery.

If-Else is a difficult for 11-13 year olds to conceptualize. That is OK. This project can be modified to work with the simple IF statement first, before trying the IF-ELSE.

TEACHER GUIDANCE: Handout is two pages: first page is helper for project; second page is helper for the concept of Branching.

Students may ask what is the difference is between these commands:

With "When this sprite Clicked: pointer needs to click on the sprite.

With if < touching >, pointer touches ( passes over )the sprite, there is no need to click.

Close-Out (5 minutes)

Close-Out (5 minutes)

    1. Discuss the following questions:

      • Give me an example of an IF-ELSE statement. eg. "IF it rains, I take an umbrella, ELSE I take my sunglasses."

      • What is the "condition" that is being tested? (Raining?)

      • Draw the example condition tree as a flowchart on the white board. Ask class to follow along with flow of the script.

        • If TRUE, what will happen? If False, what will happen?

      • Below is an example of the flowchart that the teacher would draw on the whiteboard using the students example condition.

        • Note: In a flowchart, conditions (eg raining?) are always in diamonds and commands (eg. take sunglasses) are always in rectangles.

If TRUE, what will happen? If False, what will happen?

Potential Responses

  • If True, take the umbrella.

  • If False, take the sunglasses