Class 20 — Friday March 4

"if" and "else" and Range

This is the beginning of anyting you want

Look both ways


Agenda


Downloads


To do


Choose your own adventure!

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



Problem arrangements.py

  • The start value is m; the stop value is less than n; and the other values go up in steps of k
  • The start value is m; the stop value is greater than n; and the other values go down in steps of k

Enter integers m, n, and k: 3 8 2

i: 3

i: 5

i: 7

list( range( m, n, k ) ): [3, 5, 7]

Enter integers m, n, and k: 10 6 -3

i: 10

i: 7

list( range( m, n, k ) ): [10, 7]



 


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