Day 15

Instructional Day: 15

Topic Description: This lesson provides an introduction to the concept of conditionals.

Objectives:

The students will be able to:

Explain the concept of conditionals.

Enhance a variable program with conditionals.

Outline of the Lesson:

Journal Entry (5 minutes)

Conditional lecture (15 minutes)

Age program (10 minutes)

Age solutions (5 minutes)

Enhance variable example (20 minutes)

Student Activities:

Complete journal entry.

Participate in discussion of conditions.

Develop an Age program.

Review Age solutions.

Enhance the variable example.

Students will do the following:

You are going to finish a program that will tell you what you can do depending on your age. Use the slider to set the age.

Finish this program: https://scratch.mit.edu/projects/89573040/

1. Currently, it only does the first condition. Your task is to finish the program so that the cat will tell you the rest:

If you are older than 2 "you don't need diapers"

If you are older than 15 "you can drive"

If you are older than 16 "you can see an R rated movie"

If you are older than 17 "you can vote"

If you are older than 20 "you can gamble"

If you are older than 24 "you can rent a car"

If you are older than 49 "you can retire"

2. If the age is less than 3, make the code tell you:

"Sorry, you are not old enough for anything yet"

3. Feel free to add more conditions.

Journal Entry: What comes to mind when you hear the word “if”? What are some ways we use the word “if” in English?

o Time the students so they work 3 minutes individually and 2 minutes sharing with their elbow partners.

Conditional lecture o Have a few students share their responses for the “if” parts and use that as a springboard.

o In English, if is used to state a condition where something might happen if the condition is true. Hence this topic is called conditionals. Point out that this is a common computer science construct.

o An example from computing is when a program like Microsoft Word asks you if you want to save your work when you hit close. If you click yes, it saves your changes. If you click no, it discards your changes.

o if (some condition)

§ then do this o Show students “if” block in Srcatch.

§ Notice that only hexagon shaped blocks can fit within it.

§ Notice that if the condition is true, it will do anything that is enclosed within the top and bottom of the “if” block.

o Show the students age.doc and age.sb.

§ Remind students that since we are using integers (whole numbers) > 15 it means people that are over 15 not including 15.

§ Show them how to use the slider to change the age.

Age Program

o For solution, see age solution.sb.

Age solutions o Show a solution like age solution.sb.

o Show an alternate solution.

§ Since numbers are integers (whole numbers) we can do “age > 2” to mean “age >= 3”.

§ To do >= in scratch, you need to use the “or” block. See age – greater-equal.sb.

Enhance variable example o Instruct students to go back into their variable example about nutrition and add:

§ A message about being nutritious if the number of points becomes greater than 9.

§ A message about eating healthier food if the number of points becomes less than –4.

§ They can either have a sprite say the message or use broadcast to change the sprites/stage to convey the message.

Resources:

Age Project

age.sb

age solution.sb

age – greater-equal.sb

variable example.sb

Age Project

You are going to finish a program that will tell you what you can do depending on your age. Use the slider to set the age.

1. Currently, it only does the first condition. Your task is to finish the program so that the cat will tell you the rest:

If you are older than 2 "you don't need diapers"

If you are older than 15 "you can drive"

If you are older than 16 "you can see an R rated movie"

If you are older than 17 "you can vote"

If you are older than 20 "you can gamble"

If you are older than 24 "you can rent a car"

If you are older than 49 "you can retire"

2. If the age is less than 3, make the code tell you:

"Sorry, you are not old enough for anything yet"

3. Feel free to add more conditions.