Computer Science – Truth Jam Table JamBreadSandwich Yes No YesNo YesNo TeaMilkDrink No Yes NoYes...
-
Upload
barbra-summers -
Category
Documents
-
view
215 -
download
0
Transcript of Computer Science – Truth Jam Table JamBreadSandwich Yes No YesNo YesNo TeaMilkDrink No Yes NoYes...
Computer Science – Truth Jam TableJam Bread Sandwich
Yes Yes YesNo No NoYes No NoNo Yes No
Tea Milk Drink
No No NoYes Yes YesYes No YesNo Yes Yes
What am I getting at?
Quick – homework recap
• In September
• I requested that you went away and took part in some self study.
• Code academy gives you the opportunity to learn at your pace and back up your learning in class.
• I asked for 20%...by today.
Success Criteria
• You must be able to recall the 3 boolean operators and understand their context
• You must be able to name the six arithmetic tests that can be used to create Boolean values.
• Should be able to apply these boolean operators within coded solutions
• Could be able to code your own programs of your own design using boolean operators
Boolean – Think of some expressions to illustrate these operators
Operator Some examples
AND Wet and cold
OR Black or white
NOT I’m happy NOT sad
Boolean – Think of some expressions to illustrate these operators
Boolean ‘Jamspression’
Jam =Bread =
if ( Jam and Bread ): print (“Then you can have a jam sandwich”)else: print (“well, you'll either have: Jam or sandwich but not a jam sandwich”)
AND
Boolean – Think of some expressions to illustrate these operators
Boolean ‘teaspression’
tea = 0milk = 1
if ( vodka or coke ): print ("well , you'll get a drink of some kind“)else: print ("you will get no drink at all“)
OR
Boolean – Think of some expressions to illustrate these operators
Boolean ‘Contradictspression’
a = "True"
if not( a ): print "True"else: print "False"
NOT
Sort task
• Stand in a line
• IF You < the person on your right: then move right = one stepElse: move left = one step
Boolean – Think of some expressions to illustrate these operators
spider=raw_input("Is there a spider? - Type Yes or No")
if ( spider == "Yes" ): print "Run Away!"else: print "Relax"
EQUALS TO
Boolean – Think of some expressions to illustrate these operators
a = 10b = 20
if ( a == b ): print "they are the same"else: print "they are different"
EQUALS TO EXAMPLE
Boolean – Think of some expressions to illustrate these operators
a = 50b = 20
if ( a <= b ): print "a is smaller"else: print "a is bigger"
EQUALS TO EXAMPLE
Boolean – Think of some expressions to illustrate these operators
spider=raw_input("Is there a spider? - Type Yes or No")
if ( spider == "Yes" ): print "Run Away!"else: print "Relax"
EQUALS TO EXAMPLE
Really quick Progress check
• The three boolean operators...
• Name me the arithmetic operator tests...
Using boolean expressions...
• Write:
• A program that controls the central heating system. Below 15 degrees and it’ll switch on.
• A program that signals to a person if their phone is fully charged.