U4Ch1L5_Conditionals Explore Gradesheet

Purpose: Students learn the basics of conditionals.
Vocabulary: Boolean, Comparison Operators, Logical Operators


Rule: “If” vs. “When”  - We want to be careful about how we use these words. 


Do It…
Boolean Expressions with a Comparison Operators
  
(Circle True or False)

6-3

< 

5

True    or    False

12/6

>

3

True    or    False

(7+5)*3

<=

10

True    or    False

9+5

= =

14

True    or    False

Answer

A Simple Model Flowchart for Boolean Values and a Variable:

Scenario: 

Do It…
Boolean Expressions Variables
   (Circle True or False)

Mom says 7

var time

time < 8

True    or    False

Dad says 9

var time

time < 8

True    or    False

Friends say 11

var time

time <  8

True    or    False

Answer

Model Flowchart for Multiple Variables

Boolean Expressions with Multiple Variables   (Circle True or False)

I win the game if:     my Score * my Lives   is greater than 10.

var score, var lives

score = 3, lives = 3

score * lives > 10

True    or    False

var score, var lives

score = 1, lives = 10

score * lives > 10

True    or    False

var score, var lives

score = -5, lives = 2

score * lives > 10

True    or    False

Answer



Challenge!
View the flowchart shown above in order to create a flowchart for the following scenario. Hint: The flowchart you create will differ from the ‘Model’ above, because a 1st condition must be true in order to see if it then meets the 2nd condition. If at anytime the answer is False, then you can’t proceed. Scenario: “You can adopt a dog at the SPCA if two conditions are met: 1. “Age” 14 and over, and 2. “Money” is $50. After you draw the flowchart, then superimpose the following values onto your flow chart and with arrows, show the path that was followed based upon whether or not the conditions were met. (When finished, compare your flowchart to the other student’s flowcharts – answer on class site..) 
Create a flowchart for a scenario that requires several steps.

1. “Age” 14 and over, and 2. “Money” is $50.

Scenario #1

var age,
var money

age = 17,  money = $39

True    or    False

Scenario #2

var age
var money 

 age = 12
money = $62
 True  or  False

Draw Custom Flowchart To Match Scenario

When finished, compare your flowchart to the other student’s flowcharts – answer on class site.
Answer



Truth Tables – Used in evaluating Boolean Expressions.
Read the rules for ‘&&’ ‘||‘ ‘!’ and then attempt to answer the scenarios.
Answers on class site.

&&     AND

True

&&

True

True    or    False

True

&&

False

True    or    False

False

&&

True

True    or    False

False

&&

False

True    or    False

||    OR

True

||

True

True    or    False

True

||

False

True    or    False

False

||

True

True    or    False

False

||

False

True    or    False

Answer_AND Answer _OR


 

Video: Programming with Boolean.