A variable is a named computer memory space that stores a value. The action of putting a value into a variable is called assignment. We use visualization to help us understand how Python executes an assignment statement. We also continue our discussion from last lecture on types, including conversion between types.

Lessons - watch before lecture

  1. String Expressions (6 minutes)
  2. Expressions and Order of Operation (5 minutes)
    NOTE: There is a mistake in the video. Exponentiation has higher precedence than the unary operators.
  3. Mixed Expression (5 minutes) What happens when we use an operation to combine expressions of different types?
  4. Concept of a Variable (2 minutes) A variable stores a value.
  5. Assignment Statements (3 minutes) To create a variable, assign a value to it.

Or read: 2.1 - 2.3, 2.5, 2.6 (html version)


Lecture materials

Slides: individual slides for viewing, 6-up layout for printing

You will need pencil and paper (or stylus and tablet) during lecture for drawing diagrams. We recommend that you print out the slides so that you can write and draw on them. Or have the pdf downloaded so that you can annotate on the pdf. Of course, you can take notes in a notebook, too! The key is to take notes for yourself for easy reference later.

Lecture Recording

Answers to Lecture Exercise 1 (slide 33) and Exercise 2 (slide 37): Do these super short exercises yourself first! See lecture slides file above. After drawing the diagrams yourself, you can check your answers here.