Class 20 — Friday March 19

Decisions made easy

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


Look both ways


Agenda


Program promise.py


To do list


Examples


Last Yesterclass

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 — part 1

if ( logical expression ) :

    action1

else :

    action2

if ( logical expression ) :

    action


Problem begins_with_a_vowel.py

Enter text: apple

Text begins with vowel

Enter text: banana

Text does not begin with vowel

Enter text: Orange

Text begins with vowel



The why, what, and how of an if statement — part 1

if ( logical expression1 ) :

    action1

elif ( logical expression2 ) :

    action2

...

elif ( logical expressionk ) :

    actionk

else : # optional

    actionk+1


Problem daisy_daisy.py

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

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



Problem spell_check.py

Enter text: It was the beste of times It was the wurst of times It was Oktoberfest

beste

wurst

oktoberfest

Enter text: how much wod can a woodchuck chuck

wod

woodchuck

Enter text: to be or not to be that is the question

Enter text:

  • Import our url module.
  • Specify the URL for the spelling dictionary.
  • Read the contents of the URL and store it as a list of word spellings.
  • Get the user text and convert it into a list of words.
  • For each user word determine whether it is correctly spelled. If it is incorrectly spelled, print it out.

Decision making

deciding which shoes to buy



Where am I

jpc at stonehenge

 


  🦆 © 2022 Jim Cohoon   Resources from previous semesters are available.