Lecture calendar

Notes will sometimes be posted in advance, but all notes are subject to change.

                  LecturesReading and Materials
Week 1

Lecture 1: Welcome to ESC180. Expressions and variables. A very simple program. Conditionals.

Youtube videos on tracing: Part 1, Part 2, Part 3.

Suggested readings for the next couple of lectures: Downey chapters 1-2 and/or Gries chapters 1-2. Note: you're only responsible for the material in lecture. However, some people learn best by reading, which is why I'm listing readings.

Week 2

Lecture 1: Welcome to ESC180, part 2. Conditionals, cont'd. Conditionals. A little bit on errors and how Python runs. Zoom recording

Lecture 2: The quadratic equation, string literals, numerical literals. Zoom recording.

Lecture 3: More on finite precision. Printing multiple values. Multiple assignment and swapping variables. Functions; global and local variables. Zoom recording from 2pm, Zoom recording from 4pm

Suggested readings continue reading Downey Ch. 1-2 and/or Gries Ch. 1-2.

Suggested readings: Downey Ch. 3, Gries Ch. 3

Optional aside for people who like irrational numbers: you cannot store most irrational numbers in computers: there is just not enough space to store an infinite number of digits. So what can you do? You can store a string like "pi", and hope that's interpreted in a sensible way. Of course, most irrational numbers aren't named! You can also store Python code that generates the irrational number in question to arbitrary precision (coming up in a few weeks: code to compute numbers like sqrt(2) and π). But note that there are uncountably many irrational numbers, but only countably many Python programs. That means that you still can't hope to represent almost any irrational numbers.

Happy early Talk Like a Pirate Day! Also: The distinction between "parameters" and "arguments" is not always paid attention to, but here's an explanation. A lot of the time, the terms are used interchangeably.

Challenge/job interview question: How to swap two variables without using multiple assignments and without defining an additional temporary variable? Hint: start with a = a + b. (Follow-up, requires advanced material: what if the variables are not integers?)

Week 3

Lecture 1: Passing data to and from functions. Zoom recording from 10am, Zoom recording from 3pm

Lecture 2 Types (notes to be posted). Numerical literals, cont'd. Variable naming conventions. Control flow using return. Zoom recording

Lecture 3 Integer division and modulo operators. For loops. While loops. Zoom recording.

Reading: Downey Ch 1.5, Downey 7.1-7.4 or Gries 9.1-9.3. (Note: the lecture content this week is a bit different from the way things are covered in either textbook).

For completeness: PEP 8, the official Python style guide, Python operator precedence.

Week 4

Lecture 1: More on range. Implementing range using while. Primality testing. Interview puzzle solution: swapping variables without temporary storage. Factorials and trailing zeros. Zoom recording

Lecture 2: Systematically testing code: the calculator example. import and initializing global variables outside the main block. Booleans and Boolean Algebra. Converting Booleans. Zoom recording I, Zoom recording II

Lecture 3: Postmortem debugging with Pyzo (see video). Lists and looping over lists. break and continue. Zoom recording

Videos: Computing log10 using while-loops, primality testing, tracing is_prime, Converting for-loops into while-loops

For completeness: Python operator precedence.

Just for fun, about computing exponents: how to compute b^x when x is not an integer? This is generally done by computing power series rather than repeatdly multiplying b by itself. See Lab#3 for an example of a computation of a sum of a power series.

Just for fun, about computing exponents: how to compute b^x when x is not an integer? This is generally done by computing power series rather than repeatdly multiplying b by itself. See Lab#3 for an example of a computation of a sum of a power series.

Interview question: compute the number of trailing zeros in n! efficiently for large n.

CodingBat exercises: Logic-1, Logic-2

Reading: Downey Ch. 7, Gries Ch. 9

Week 5

Lecture 1: input, and a bit on style and design. Computing Pi using a Monte Carlo method. Heterogenous lists. List methods and functions Zoom recording

Lecture 2: List methods and functions, cont'd. Pseudorandom numbers. login example: keeping track of state. Facotorials and trailing zeros: interview puazzle solution. Zoom recording

Lecture 3: login example, continued. Solution: trailing zeros of n!, the missing K problem, Interview puzzle solution: fast trailing zeros. Nested loops intro, , avoiding nested loops using functions Zoom recording.

Reading: Downey Ch. 7, Gries Ch. 9

CodingBat exercises: List-1, List-2

Interview puzzle: given a list of the numbers 1...n, with k missing and the numbers arranged in an arbitrary order, determine what k is by only making one pass over the list.

Just for fun: Unix Epoch Time

Week 6

Lecture 1: Nested loops intro, cont;d. Strings and string methods. ReversingStrings. Anagrams. intro to exec (to be continued). Zoom recording

Lecture 2: Zoom recording

Lecture 3: start reading the memory model notes. Zoom recording

Reading: Gries Ch. 4, 7.3. Downey Ch. 8

Extra practice problems: all of CodingBat Python. String-3 and Array-3 on CodingBat Java (N.B., you'd have to test the outputs yourself).

Python 3 string methods

Week 7

Lecture 1: Zoom recording. Continue reading the memory model notes. Memory model worksheet.

Lecture 2: Zoom recording. Continue reading the memory model notes. Memory model worksheet, solutions, Exercise C video solutions

Lecture 3: Zoom recording

Week 8

Lecture 1: Zoom recording

Lecture 2: Zoom recording

Lecture 3: Zoom recording

Week 9

Lecture 1: Complexity analysis lecture. Computational complexity notes. Zoom recording

Lecture 2: Pre-lecture longest_run.py. Zoom recording (Noon), Zoom recording (3pm)

Lecture 3: Zoom recording (N.B.: watch the Noon recording for Lecture 2 for an introduction to timeit.timeit(), globals(), and locals()).

Week 10

Review session: 3pm, 6:20pm

Lecture 1: Zoom recording

Lecture 2: Zoom recording (morning), Zoom recording (aftenroon)

Week 11

Lecture 1: Zoom recording

Lecture 2: Zoom recording

Lecture 3: Zoom recording

Week 12

Lecture 1:

Week 13

Lecture 1: