Skip to main content

Foundations of Python Programming: Functions First

Section 2.1 Introduction

This chapter introduces several basic building blocks of Python programs:
  • literals, like numbers and character strings
  • operators, like + and *
  • function calls, which take values as inputs and compute new values
  • variables, which save values so they can be used later in the program
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.

Subsection 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

Subsection 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
You have attempted of activities on this page.