M, F 2:30-3:20
in Olin 165

CS 1133: Short Course in Python

Fall 2017

Lecture Summaries

This page lists a summary of the activities of each week, in reverse chronological order. This is your go-to page for downloading in-class handouts and getting caught back up if you get behind. This page is updated dynamically all semester long, with new material added as we get there.

If you want to see what future lectures in this class will be, you should look at the syllabus page.


Week 7

6 October (Friday): Using Classes Effectively

[Handout]      [Presentation]
Demos
ctime.py
rect.py
card.py
hand.py
frac1.py
frac2.py


Programming with classes can be very confusing if you have never used them before. For the last class, we will not be introducing (much new Python). Instead we will talk about how you design classes, and what classes should be used for. In particular, we show how to use classes to create mathematical types like fractions or complex numbers.

Reading: Chapter 17



Lab 6: Objects and Classes

[Instructions]

This is the very last lab of the course. It gives you some experience with objects, which are a very important part of Assignment 2. If you can do this lab, you should have no problem with that assignment.


2 October (Monday): Classes

[Handout]      [Presentation]
Demos
example.py
example2.py
point.py
worker.py


Up until now, if we wanted to use objects, we had to import a module that provided them for us. Today we finally learn how to create our own classes. Not only can we make our own class types now, but we can even add them to the Python visualizer.

Reading: Chapters 15, 16



Week 6

29 September (Friday): Memory in Python

[Handout]      [Presentation]
Demos
globals.py
reorder.py
anglicize.py


Throughout the past few weeks, we have seen several different ways of representing memory in Python. Today we put everything together, introducing global space, heap space, and the call stack. The latter is the collection of frames for all currently executing functions.



Lab 5: Lists and Control Structures

[Instructions]

Now that you have worked on Assignment 1, we can start introducing new Python concepts. Two weeks ago introduced simple control structures. Last week we introduced lists and objects. Today you will put all of these to good use by implementing some simple functions.


25 September (Monday): Dictionaries and Objects

[Handout]      [Presentation]
Demos
grader.py
pfuncs.py


Today, we introduce the two new data type: dictionaries and objects. While these types behave very differently, they are actually very similar when we look at their memory representation. Objects will be a major part of Assignment 2.

Reading: Chapter 11



Week 5

22 September (Friday): For-Loops

[Handout]      [Presentation]
Demos
loops.py
ranges.py


Lists (and sequences) come with their own special control structure: the for-loop. In this lecture we see what for-loops can (and cannot) do to make more interesting programs.

Reading: Sections 8.3, 8.7, Chapter 10



Lab 4: Assignment 1

[Instructions]

In recognition of the looming assignment, today's lab is a chance for you to work on Assignment 1. There are some optional exercises on the lab, in case you want some more practice in addition to Assignment 1. However, these are not necessary and you will get credit for the lab so long as you turn in Assignment 1 on time Sunday night.


18 September (Monday): Lists (and Sequences)

[Handout]      [Presentation]

Now that you are an expert of string slicing, we introduce another sliceable data type: lists. Lists behave just like strings, except that they can contain data other than text. They are also mutable, which means we need to use folders to represent them.

Reading: Sections 10.1-10.2 and 10.4-10.6



Week 4

15 September (Friday): Conditionals and Control Flow

[Handout]      [Presentation]
Demos
name.py
debug_name.py
test2.py
flow.py


Today we talk about the difference between program structure and program flow. We also introduce the conditional, which is our first program structure for controlling program flow. This will not be necessary for Assignment 1, but will be very important in later assignments.

Reading: Sections 5.1-5.7



Lab 3: Strings and Testing

[Instructions]

This week's lab is the most important one all semester. It covers a lot of important topics that you will need before you can start on the first assignment. In particular, you will learn how properly test the functions that you create.


11 September (Monday): Specifications and Testing

[Handout]      [Presentation]
Demos
greet.py
temp.py
name.py
debug_name.py
test1.py
test2.py


We now know how to write some complex functions. However, writing functions takes a lot of practice and you are likely make mistakes along the way. That is why it is extremely important to test your functions and make sure they are working properly. As part of testing, we will also see why comments are more important that just notes to yourself.

Reading: Docstrings in Python



Week 3

8 September (Friday): Strings

[Handout]      [Presentation]
Demos
greet.py
middle.py
pvr.py
commalist.py


Python really shows off its power when working with text. Today we go into depth about the string type, which is how Python represents text. We show how to cut up text and paste it back together. The techniques that we learn will be very important for the first assignment.

Reading: Sections 8.1-8.2, 8.5, 8.8



Lab 2: Modules and Functions

[Instructions]

The purpose of this lab is to get you comfortable with using functions and modules provided by Python library. You will also get to write your first (simple) function and put it into a module.


Week 2

1 September (Friday): Defining Functions

[Handout]      [Presentation]
Demos
plusone.py
foo.py
temp.py
globals.py


Now that we know how to use functions, we can learn how to create our own functions. As part of this, we will learn the important difference between a function call and a function definition.

Reading: Chapter 3



Lab 1: Expressions and Assignments

[Instructions]

The purpose of this lab is two fold. First, it is designed to get you started with Python immediately. Second, gives you hands on experience with Python expressions, which we talked about on the first day of class.


28 August (Monday): Functions and Modules

[Handout]      [Presentation]
Demos
module.py
script.py
helloApp.py
plusone.py
temp.py


Today we introduce the concept of a module and show how they provide Python with extra (optional) functionality. We show how to use the many modules built into Python, and how to make our own modules.

Reading: Sections 3.1-3.3



Week 1

25 August (Friday): Variables and Expressions

[Handout]      [Presentation]

We give an overview of the course and its expectations. We show you how to get started with Python. Finally, we talk about types and variables, which is the bare minimum that you need to do something "useful" in Python.

Reading: Chapters 1 and 2