Class 4 – Wednesday, August 30

Variation on a theme

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


Look both ways


Agenda


Important questions


Examples of the day

What the solution offers

  • Introduces the assignment operator =. The = operator causes the variable to its left to get the value of the expression to its right.
  • The ability to update is crucial when problem solving.
  • 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 what is on the user's mind
  • Echo (print) the reply
  • Prompt and get why the first reply is on their mind.
  • Prints ooh

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.
  • Also 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.
  • The final version of the program reflects echoing of the first input before printing the second prompt

What the solution offers

  • Uses the built-in cast functions int() and float() to convert numeric strings into the numbers they represent.
  • The final version of the program shows the two casts using built-in functions int() and float() to convert the supplied string-based inputs into numerics.

What the solution offers

  • Introduces the string member function split(). Its called a member because every string can be called upon to produce a split up version of itself. The value of a split() invocation is the list of substrings (words) that make up the string being told to split(). The function is handy for breaking up user input into its individual parts.
  • The final version of the program shows that every string has a member function for inspecting itself. The split() function hands back the list of words that make up the string.



Tips of the day


To do list




rabbits galore