For this class, you should know Python. In particular, you should know all about the basic building blocks and concepts of this programming language as summarized below. Each section has a link to a longer page (with exercises) that you can use for review.
Table of contents
Python interpreter and the first program
See Hello World to review:
- using the
python
andipython
interpreter - writing a Python program with your editor
- executing a Python program from the command line
python program.py
Variables, expressions, data types
See Variables, expressions, data types to review:
- comments in Python (
#
) - variables and assignments
- naming
- assignment operator
=
- outputting values with
print()
- dynamic typing
- simple variable types
- numeric types:
int
,float
,complex
- text sequence (string):
str
- boolean values
True
andFalse
, truthiness in Python - None-data type:
None
- casting (type conversion)
- numeric types:
- expressions
- operators
- precedence
- container data types (with
len()
)- lists
list()
,[1, 2, ...]
- indexing
a[3]
,a[-1]
(zero-based!) - slicing
a[start:stop]
,a[start:stop:step]
- mutable
- indexing
- tuples
tuple()
,(1, 2, ...)
,1, 2, ...
(at least one comma)- indexing
- slicing
- immutable
- tuple assignment
a, b = -2, 3
- dictionaries
dict()
,{key: value, key: value, ...}
- item access
d[key] --> value
- no order
- mutable
- item access
- lists
Flow Control
See Flow Control to review:
- code blocks, indentation, and white space
- loops
for
loop- iteration over sequences
for x in ["one", "two", "three"]:
- iterating with
range()
:for x in range(10):
- list comprehensions:
squares = [x*x for x in range(10)]
- iteration over sequences
while
loop:while <expression>:
- loop control with
break
andcontinue
- conditional:
if <expression> ... elif <expression> ... else
Functions
See Functions to review:
- defining a function (
def f(...)
)return
value- doc string
- arguments
- keyword arguments (with default values)
- calling a function
value = f(...)
Modules and Packages
See Modules and Packages to review.
Objects
See Objects to review.