Class 4 – Wednesday, January 23

Variation on a theme

A variable — Is like a box or a name — We must all know this

That Black Lives Matter — Should be so easy to grasp — People are people


Look both ways


What is happening today


Download right now


Download as soon as you can


A code walk through — getting a mental model of variables and assignment


In-class comportment


Agenda


Important questions


Problems of the day

What the solution offers

  • Basic understanding of variables and assignment.
  • The ability to update is crucial when problem solving.

Check out


What the solution offers

  • Examines some nuances of the assignment operator.
  • The final version of the program updates the value of variables in terms of themselves; ie., number of rabbits doubles each generation and the generation number is an increment of the previous generation value.

Problem

  • Prompt and get a word of interest from user user
  • Compute the length of the word
  • Output a message about the length of the word

What the solution offers

  • Introduces built-in function input(). When the function is invoked, its argument is printed to the display, the entry supplied by the user in response to that message is the value of the invocation. The input() function always returns the user reply as a string.
  • The input() function allows programs to be interactive; i.e., their actions can be influenced by the user. The input() function enables Python to do general problem solving.

Three possible program runs

Tell me a favorite word: rhythms

 

Did you know that rhythms has length 7

Tell me a favorite word: strengths

 

Did you know that strengths has length 9

Tell me a favorite word: squirreled

 

Did you know that squirreled has length 10


Problem

  • Prompt and get what is on the user’s mind
  • Prompt and get why the first reply is on their mind.
  • Print an out of time message

What the solution offers

  • Introduces the str type operator +. The + operator when evaluated with two strings as its operands, produces as its value, their concatenation.
  • Another use of the built-in function input().
  • Creates and uses an input prompt that makes use of a prior input.

Three possible program runs

Tell me what is on your mind: I worry about the future

 

Hmmm. Why is -- I worry about the future -- on your mind: Because it it coming

 

Oh? I wish we had more time to chat. So long.

Tell me what is on your mind: A fluttering butterfly

 

Hmmm. Why is -- A fluttering butterfly -- on your mind: I do not want rain

 

Oh? I wish we had more time to chat. So long.

Tell me what is on your mind: Is superman colorblind

 

Hmmm. Why is -- Is superman colorblind -- on your mind: To account for fashion sense

 

Oh? I wish we had more time to chat. So long.


To do list




wikimedia creative commons license rabbits galore





selfie at Woodlands Elemenary Walk for MLK





wikimedia creative commons license dabchick