Class 20 — Friday October 9

Decisions made easy

I am positive — My favorite color is hue — Easy decision


Look both ways


Agenda


To do list


Examples


Last class

if ( logical expression1 ) :

    action1

elif ( logical expression2 ) :

    action2

...

elif ( logical expressionk ) :

    actionk

else : # optional

    actionk+1



Problem who_is_the_longest_of_them_all.py

Some possible program runs

Enter text: Think before I act — My problem solving mantra — Make it your also

problem

Enter text: Remember always — Seek to be both great and good — The world needs your aid

Remember

Enter text:

 

Brainstorming

  • If it is the longest word we seen so far, then we need to remember it in order to compare it to the remaining words.
  • If it is not the longest word we seen so far, we take no further interest in it.

Problem spell_check.py

Three possible program runs

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:

Brainstorming

  • 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

Problem who_are_the_longest_of_them_all.py

Three possible program runs

Enter text: Think before I act — My problem solving mantra — Make it your also

['problem', 'solving']

Enter text: Remember always — Seek to be both great and good — The world needs your aid

['Remember']

Enter text:

[]

Brainstorming


Puns of the day

calves from www.pexels.com/photo/agriculture-cows-curious-pasture-33550/

Law of Cole — visualization

slaw from www.flickr.com/photos/30478819@N08/43166268351 license=creativecommons.org/licenses/by/2.0/

 


  © 2020 Jim Cohoon   Resources from previous semesters are available.