computer science – truth jam table jambreadsandwich yes no yesno yesno teamilkdrink no yes noyes...

21
Computer Science – Truth Jam Table Jam Bread Sandwi ch Ye s Ye s Ye s No No No Ye s No No Tea Milk Drink No No No Ye s Ye s Ye s Ye s No Ye s No Ye Ye What am I getting at?

Upload: barbra-summers

Post on 04-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

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.

Computer Science 3.1.1

Constants_variables and data types 2

Where are we starting at?

• Writing programs using Boolean:

Uh? Mmmm... Yeah!

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

Quick recap

• What is boolean?

• How could you illustrate it? Symbols?

Boolean - True or False

Operator

AND True only if...

OR True if...

NOT True if...

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

Quick warm up

• Create a boolean expression using AND, OR and NOT

• 10 minutes

Six arithmetic testsOperator What is it?

<<===!=>=>

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.

Homework

• Show me evidence:

• What is a list / array used for?• Evidence that you can create a list / array• Evidence that you can write code to

manipulate* a list / array

*search, index, add, append, change, print etc etc.