Skip to the content.

Detailed schedule and resources

Class 24

Class 23

Class 22

Class 21

Class 20

Class 19

Class 18

Written exam 1

Class 17

Exam review – bring questions to discuss.

Class 16

Social/Ethical class III: Social good in computing. The article for discussion is available on the Readings web page.

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.

Class 12

Warmup: Draw the stack diagram for the program callstack_warmup.py in the following situations:
(a) Immediately before line 12 is executed
(b) Immediately before line 8 is executed

Announcement:

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

Announcements about homework:

  1. Don’t comment out code when turning in solutions any more. We will encapsulate code in functions instead.
  2. For homework, make sure to write your code in IDLE and test it. When it’s working perfectly, then copy and paste it into your homework document.
  3. For homework, if using Microsoft Word, start with the assignment document. Then you can format the code by using the “code” style. If you get a lot of space between the lines, then use “Remove Space After Paragraph” (select text, maybe right click, look for line spacing option).
  4. Make sure your code is in a fixed width font like Consolas or Courier. (Why??)

Introductions: 2nd row, get ready

Today is 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 first, don’t peek unless you need to) decide.py

Also Boolean variables and parameters – see SSG12.

Class 8

Today we cover chained conditional statements and nested conditional statements.

Solution to warmup exercise: warmup.py.

Additional example (Not covered in class): convert_miles2.py

We will also go over sections 9 to 11 of the supplementary study guide, which are needed for lab this week.

Complete example for using graphics.py with familiar coordinate system: graphics_example.py

Class 7

More introductions: front row, get ready with your first-year seminar topic and instructor and what you liked about the course.

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

Class 6

Announcements:

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

Code: graphics_demo.py, grid.py; other code from today was copied directly from the study guide.

Class 5

Agenda for today’s class:

  1. In-class exercise to build familiarity with for loops:
    • A. (warmup) Write code that prints out the result of rolling a 20-sided dice.
    • B. Write code that prints out the results of rolling a 20-sided dice 100 times.
    • C. Write code that computes and prints the average value of the rolls in the previous simulation (rolling a 20-sided dice 100 times).
  2. We’ll go over the supplementary study guide content about for loops, which explains how to use the loop variable.
  3. Run a basic turtle program.

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

Code (suggest don’t peek): roll_dice_once.py, roll_dice_100times.py, average_100_rolls.py, draw_square.py

Assignment statement explanation:

assignment statement explanation

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 comments, but we did not discuss that during class.

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.

Code: border.py, roll_dice.py

Class 3

If campus is closed on Monday, class will take place online via Zoom. The link and details are on the course home page.

Today we review the concepts in the assigned reading, including: variable names, keyword, import, dot operator, statement, expression, evaluation, execution, argument, comment, function definition, header, body, parameter

Example programs (suggestion: don’t peek before class): area.py, ask_question.py

Class 2

  1. Answer questions on syllabus. Especially note the 5 exam dates.

  2. Demo: AI can easily do your homework assignments. But it’s a really bad idea to rely on it, because you won’t have AI in the exams.

  3. Interactive textbook: You can interact with the textbook by reading it in the form of Jupyter notebooks. Links to the notebooks are on the very first page of the textbook.

  4. We will review concepts in the assigned reading, including some of the following: arithmetic operator, type (this is what I usually call a datatype), expression, function, function call, bugs and debugging, variable, assignment statement, state diagram, input().

  5. [If time allows.] Play with some more Python progams (see suggestions in class 1).

Class 1

Announcement: This class separates into two separate sections for labs: COMP130-01 on Fridays 3-5pm and COMP130-02 on Wednesdays 3-5pm. Currently there are significantly more students signed up for the Wednesday section. If you would like to switch to the Friday section (and thus receive more individualized help from the instructor and quantitative reasoning associate), please drop your current section and add yourself to the other section.