2.1. Introduction

This chapter introduces several basic building blocks of Python programs:

These are the basic building blocks that are assembled to create programs that you interact with everyday—from the software running on your smartwatch, to the infrastructure behind the largest websites, and every app running on your phone.

2.1.1. Learning Goals

  • To understand Python’s storage model
  • To solve problems using the ‘accumulator pattern’
  • To understand operator precedence
  • To distinguish between expressions, values, and printed representations
  • To recogonize & explain hard coding

2.1.2. Objectives

  • Given some sample code identify variables that reference an object of a particular type
  • Given a variable of one type convert it to another
  • Simulate evaluation of an expression and assignment statement
  • Use reassignment to increment a variable (accumulator pattern)
  • Get input from a user and convert the input to the appropriate type
  • Identify the following types of values: strings, integers, floats, functions
  • Recognize valid vs. invalid variable names
  • Write an assignment statement
  • Update a reference diagram after reassignment
Next Section - 2.2. Values and Data Types