Lesson 01: Everything is an object (and other preliminaries)
Let’s start learning Python. This week we focus on the basics: Python objects, variables, types, operators, statements and expressions.
Readings
Below are a set of readings that you should consider reviewing. Note that the Real Python articles referenced below may require signing up for a free account.
1.0 Required
Charles Severance, Python for Everybody. Exploring data in Python 3 (CreateSpace, 2016).
💡 An English-language version of Chuck’s book is available as a PDF or ePub in the Canvas Files texts
folder. Other translations and formats are available online.
Read Chapter 2, “Variables, Expressions, and Statements”. Peruse this chapter first, then proceed to the other readings.
Eric Matthes, Python Crash Course, 3rd ed, (No Starch Press, 2023).
Chapter 02, Variables and Simple Data Types.
Overlaps the Severance material but presented in a way that’s easy to comprehend and consume.
Chapter 08, Functions.
Read the following introductory sections:
- Defining a Function
- Passing Information to a Function
- Arguments and Parameters
- Passign Arguments
- Positional Arguments
- Multiple Function Calls
- Order Matters in Positional Arguments
Lisa Tagliaferri, An Introduction to Working with Strings in Python 3 (DigitalOcean, Sept 2016).
2.0 Recommended
Below are a set of optional readings that you should consider reviewing. Note that the Real Python articles referenced below may require signing up for a free account.
Dan Bader, The Meaning of Underscores in Python (dbader.org, n.d.).
Dan discusses the semantics of the underscore (_
) character and its use in variable names.
Trey Hunner, Overlooked facts about variables and objects in Python: it's all about pointers (Trey Hunner, March 2022).
Trey prefers to employ the term “pointer” to describe the relationship between a variable and the object it references.
John Sturtz, Operators and Expressions in Python (Real Python, nd).
Read the following sections:
- Arithmetic Operators
- Comparison Operators
- Logical Operators
- Logical Expressions Involving Boolean Operands
- Evaluation of Non-Boolean Values in Boolean Context
- Built-In Composite Data Object
- Logical Expressions Involving Non-Boolean Operands
- Chained Comparisons
- Identity Operators
- Operator Precedence
- Augmented Assignment Operators
John Sturtz Variables in Python (Real Python, nd).
Discusses variables, variable naming, variable assignment, object references and identity. Thorough in its coverage.
Jake VanderPlas, A Whirlwind Tour of Python (O’Reilly Media, 2016).
Read section Basic Python Semantics: Variables and Objects.
A short section that should help clarify what constitutes an object in Python (in short, nearly everything) and how to think about variables.
Jake’s Github repo also contains an online version of his report.
3.0 Reference
w3schools.com, Python Built-in Functions (w3schools.com, nd).
w3schools.com, Python Operators (w3schools.com, nd).
w3schools.com, Python String methods (w3schools.com, nd).
Bookmark these pages.