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
Agenda
- Further expand our communication and abstraction skills
- Expand our understanding of variables
- Introduce assignment
- Introduce input acquisition
- Get adept at casting
- Improve CS 1112 now and in the future
Please help us help you
- Take a survey
Important questions
- What is a variable?
- Why is assignment so important
- Does the old value of a variable hang around for us to use?
Problems of the day
What the solution offers
Basic understanding of variables and assignment.
What the solution offers
- The ability to update is crucial when problem solving.
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 what is on the user’s mind
- Echo (print) the reply
- Prompt and get why the first reply is on their mind.
- Prints Oh!
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. Theinput()
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. Theinput()
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()
andfloat()
to convert numeric strings into the numbers they represent.
- The final version of the program shows the two casts using built-in functions
int()
andfloat()
to convert the supplied string-based inputs into numerics.
To do list
- Review class artifacts
- Ensure familarity with Python variables, assignment, and input
- Complete the current assignment
- Read, but do not do, the next assignment