Section 2.1 Introduction
Subsection 2.1.1 Python Building Blocks
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.2 Learning Goals
- To understand Pythonβs storage model
- To understand how to assign values to variables so they can be stored and reused
- To understand operator precedence
- To distinguish between expressions, values, and printed representations
- To recognize & explain hard coding
- To understand how to get input from an end user
Subsection 2.1.3 Objectives
After completing the exercises in this chapter, you should be able to:
- 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
- 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.