Notes will sometimes be posted in advance, but all notes are subject to change. Old notes from 2022 are available for reference, and will be refreshed throughout the semester
Lectures  Reading and Materials  

Week 1 
Lecture 1: Welcome to ESC180. Expressions and variables. A very simple program. YouTube livestream 
Suggested readings for the next couple of lectures: Downey chapters 12 and/or Gries chapters 12. Note: you're only responsible for the material in lecture. However, some people learn best by reading, which is why I'm listing readings. Learning outcomes: be able to run a very simple Python program in Pyzo. Undrestand that a program is a series of instructions. Understand what syntax is, both in natural (human) languages and in programming langueges 
Week 2 
Lecture 1: Welcome to ESC180, part 2. Conditionals, cont'd. Conditionals. . YouTube Livestream Youtube videos on tracing: Part 1, Part 2, Part 3. Lecture 2: A little bit on errors and how Python runs. The quadratic equation, string literals, 2022 Zoom recording. YouTube livestream Lecture 3: numerical literals. More on finite precision. Functions; global and local variables. 2022 Zoom recording ver. 1, 2022 Zoom recording from ver. 2. YouTube livestream 
Suggested readings continue reading Downey Ch. 12 and/or Gries Ch. 12. 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. Learning outcomes: Be able to trace Python programs in Pyzo. Understand the distinction between syntax errors and "name not found" errors in Python. Be able to identify some syntax errors and some name not found errors in simple examples. Understand that Python executes code linebyline and understand why Python cannot find "name not found" errors ahead of time. Understand that string, float, and int types are different. Understand the difference between int and floats types. Understand the limitations of the float types. Understand why comparisons between floats and ints can be problematic. Understand why physical measurements can usually be stored in a float. Understand conversion between different types, and understand why e.g. "42" + 42 will produce an error but "42" + str(42) won't. Be able to write very simply functions that perform mathematical operations. 
Week 3 
Lecture 1: Multiple assignment and swapping variables. Functions; global and local variables, cont'd. Passing data to and from functions. 2022 Zoom recording from 10am, 2022 Zoom recording from 3pm. YouTube live stream 2m, YouTube livestream 3pm. Lecture 2 Functions; global and local variables, cont'd. Types (notes to be posted). . Zoom recording. YouTube livestream Lecture 3 Passing data to and from functions, cont'd. Integer division and modulo operators. For loops. While loops. Zoom recording. YouTube livestream Control flow using return 
Reading: Downey Ch 1.5, Downey 7.17.4 or Gries 9.19.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. 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. (Followup, requires advanced material: what if the variables are not integers?) Learning outcomes: Be able to write simple functions. Understand the different ways information is communicated to functions: passing an argument, modifying a a global variable to be read by the function. Understand the different ways information is communicated from functions: via return, and by modifying a global variable. Understand how for and while loops work. Be able to write for and while loops, particularly in the context of computing quantities such as x^n and properties of numbers such as primality. 
Week 4 
Lecture 1: Primality testing, cont'd.Implementing range using while. Intro to Project 1. Systematically testing code: the calculator example. import and initializing global variables outside the main block. YouTube livestream (2pm), YouTube livestream (3pm) Lecture 2: While loops, More on range, Implementing range using while, Factorials and trailing zeros, YouTube livestream, Lecture 3: Debugging with Pyzo. Interview puzzle solution: swapping variables without temporary storage. Factorials and trailing zeros. Systematically testing code: the calculator example. import and initializing global variables outside the main block. Booleans and Boolean Algebra. Converting Booleans. YouTube livestream, backup Zoom room 2022 stuff below: Lecture 1: More on range. Implementing range using while. . 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 whileloops, primality testing, tracing is_prime, Converting forloops into whileloops 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: Logic1, Logic2 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: List1, List2 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. String3 and Array3 on CodingBat Java (N.B., you'd have to test the outputs yourself). 
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: Prelecture 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 
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: Recorded lecture I, 0:38minend, Recorded lecture 2, 0:0min0:25min (passcode a99887766!) Lecture 2 Recorded lecture (passcode: a99887766!) Lecture 3: Recorded lecture 1, 0:25minend, Recorded lecture 2. 0:0min0:30min, everything else optional. (passcode a99887766!)  
Week 13 
Lecture 1: Zoom recording MergeSort, MergeSort analysis, MergeSort analysis II (optional, not covered in lecture) Lecture 2: Turing and Goedel, call tree review, recursive deep copy (optional, not covered), Monte Carlo Integration (only need to know the concept of computing integrals by throwing random points on the plane, and the issues around computing f_max). Zoom recording AM, Zoom recording PM (incomplete). 