Skip to the content.

Detailed schedule and resources

Class 36

There is no class meeting for this lecture slot. A prerecorded video lecture is available instead (links to Moodle):

Code for the video lecture is also available:

Class 35

Written exam 2.

Class 34

Exam review session.

Class 33

Class 32

Class 31

Class 30

Class 29

Class 28

Class 27

Class 26

Class 25

Class 24

Class 23

Class 22

Class 21

Class 20

Class 19

Class 18

Written exam 1

Class 17

Exam review

Class 16

Social/Ethical class III: Social good in computing. Some students were absent for legitimate reasons and requested notes on the class content, so these notes are being made available to all students out of fairness:

Class 15

Code for demonstrating guardians:

Class 14

Code for demonstrating and encapsulation and generalization:

Code for demonstrating factoring out repeated code:

Class 13

Social/Ethical discussion II. See Readings web page.

Class 12

Announcements:

Topics for today’s class:

Class 11

Demo code: debug_demo.py, callstack_demo.py

Class 10

Social/Ethical discussion I. See Readings web page.

Class 9

Mostly review of chained and nested conditional statements. We want to write a function decide(hungry, tired) that prints output according to

  hungry not hungry
tired get takeout sleep
not tired cook dinner watch Netflix

Example code: (try to figure out for yourself?) decide.py

Also Boolean variables and parameters – see SSG11.

Class 8

We cover cascading conditional statements and nested conditional statements. Example Python code: convert_miles2.py

We will also go over sections 8 to 10 of the supplementary study guide, which are needed for lab this afternoon.

Please take a look at the extra question that is in the solutions of homework assignment 2. You need to understand how to answer this type of question (distinguishing between function calls in a module and method calls on an object).

Class 7

Today we cover topics from the assigned textbook reading, including floor division and modulus, boolean expressions, relational operators (==, !=, >, >= etc.), logical operators (and, or, not), conditional execution (if, else).

Example Python code (but try to do the warmup exercise yourself before looking at this): convert_miles.py, boolean_demos.py

Optional: A “real” example of using conditionals, using the Scratch programming language: Potion making, by Scratch user cc196. Click on “See inside” then “Backdrops 1” to see a lot of nested if/elses

Class 6

Today we cover Sections 4-7 of the supplementary study guide: nested for loops; constructors; graphics.py; methods and dot notation.

Just for interest: if you want to find out about one of the areas of computer science that I’m interested in, check out today’s episode (September 8) of a radio show called The Academic Minute, which is broadcast on about 70 radio stations in North America. It’s also available as a podcast: The Academic Minute NPR podcast

Code from class (slightly improved version compared to what was shown in class): graphics_demo.py

Class 5

Agenda for today’s class:

  1. We’ll go over the supplementary study guide content about for loops, which explains how to use the loop variable.
  2. We’ll begin working through the textbook exercises in section 4.3.

Useful tip: Learn how to use IDLE’s Indent Region and Dedent Region features, in the Format menu.

Class 4

Important note about the teaching style in this course: Many concepts will not be covered during our lecture session. It is essential to read the textbook carefully and ask questions on any content you don’t understand. For example, the assigned reading for Class 3 included the important concept of string concatenation, but we did not discuss that during class.

New link on main homepage: supplementary study guide.

Plan for today: We will go over some key concepts from the assigned reading, especially how to define new functions and how to generate random numbers.

Note that for section 13.2, you are not expected to understand all of this content. The only things we need from this section are:

Hopefully you will never need this advice, but just in case…

  1. At the end of class, we saw a mysterious “unexpected indent” error from IDLE. Usually, this is caused by indenting your code incorrectly. However, it can also be caused by certain invisible characters in the Python file. Different computer systems use different specialized characters for representing the end of a line, and it is possible for IDLE to report these characters as causing an indentation error. One easy way to remove all unwanted end-of-line characters is to copy and paste your code into this end-of-line fixer website. Click “Convert line endings to LF”, copy the output into a new file, and now the weird characters have been removed from your Python script.

  2. I have also occasionally seen the presence of certain invisible characters prevent IDLE from saving a file. If IDLE refuses to save, you should create a new file and paste your code into it after following step 1 above to ensure that any weird invisible characters have been removed.

Class 3

Today we review the concepts in the assigned reading, including script mode, order of operations, string operations, comments, function calls, and math functions.

Example programs: area.py, ask_question.py

Class 2

We will review the concepts in the assigned reading, then look ahead to some things needed in the afternoon lab: commenting out code; the distinction between executing code via the console and running Python scripts.

Here are a couple of clarifications of the assigned reading material:

Pair programming will be discussed if we have time, otherwise we can talk about it in lab. Key ideas:

Class 1

—- Last modified: Thu Nov 16 22:11:30 UTC 2023 by jmac.