Class 19 — Wednesday October 7

Decisions made easy

Put cell phones away — Please do no multi-tasking — Or under-tasking


Look both ways


Agenda


To do list


Examples


Last class

Enter pH level: 6.5

True

Enter pH level: 7.0

False

Enter pH level: 7.5

False

Enter soil pH level: 6.5

pink

Enter soil pH level: 7

blue

Enter soil pH level: 7.5

blue



The why, what, and how of an if statement

if ( logical expression ) :

    action1

else :

    action2

if ( logical expression ) :

    action

if ( logical expression1 ) :

    action1

elif ( logical expression2 ) :

    action2

...

elif ( logical expressionk ) :

    actionk

else : # optional

    actionk+1


Problem begins_with_a_vowel.py

Some program runs

Enter text: apple

Text begins with vowel

Enter text: banana

Text does not begin with vowel

Enter text: Orange

Text begins with vowel



Problem daisy_daisy.py

Some program runs

Enter day of week: Sunday

weekend day

Enter day of week: monday

start of school week

Enter day of week: TUESDAY

school day

Enter day of week: Wednesday

school day

Enter day of week: Thursday

school day

Enter day of week: Friday

end of school week

Enter day of week: Saturday

weekend day



Problem robotomy.py

Some program runs

Door (locked / unlocked): locked

Turn around

Door (locked / unlocked): Unlocked

Open the door

Light (on / off): on

Enter the room

Door (locked / unlocked): unlocked

Open the door

Light (on / off): Off

Turn on the light

Enter the room




deciding which shoes to buy


Chrysanthemum morifolium 08NOV; 池田正樹 (talk)masaki ikeda [Public domain]


Chrysanthemum Blue by Sugeesh at Malayalam Wikipedia [CC BY-SA 3.0 (https://creativecommons.org/licenses/by-sa/3.0)]



Where am I

love is love celebration at the rotunda 2019

 


  © 2020 Jim Cohoon   Resources from previous semesters are available.