T-Th 9:05
or
T-Th 11:15
in Olin 155

CS 1110: Introduction to Computing Using Python

Spring 2018

## Lecture Summaries

### Week 15

#### 8 May (Tuesday): Sorting and Searching and What's Next!

[Handout]      [Presentation]
Demos
Life After CS 1110

Today we review our Partition function and use it to write QuickSort. Now that we have sorted sequences, we can discuss Linear Search and Binary Search. Finally, we discuss what to take after CS 1110.

### Week 14

#### 3 May (Thursday): Sorting

[Handout]      [Presentation]
Demos
insertion_sort.py
quick_sort.py
algorithms.py

Today we complete our discussion of loop invariants and show how to use them to implement two sorting algorithms: Insertion Sort and Quick Sort.

#### 1 May (Tuesday): Sequence Algorithms

[Handout]      [Presentation]
Demos
largest_elem.py
separate_pos_neg.py

Today we continue our discussion of loop invariants (the first page of the handout is from the last lecture's presentation), reviewing Tasks 3 and 4 from the Loop Invariants lecture. Then we introduce framework for building complex algorithms on sequences (strings, lists, etc.).

### Week 13

#### 26 April (Thursday): Loop Invariants

[Handout]      [Presentation]
Demos
pairs.py
invariants.py

Today we discuss how to design algorithms for while-loops. We introduce the notion of a loop-invariant, and show how to use that to write a program with a loop.

#### 24 April (Tuesday): NO CLASS - open office hours

No regular class. open office hours during lecture time instead.

### Week 12

[Handout]
Demos
Questions
Solutions

#### 17 April (Tuesday): Programming with Subclasses

[Presentation]
Demos
zoology.py
zoo.py

Now that we have subclasses, there is quite a bit we can do with them. Today we'll look at an in-depth example of a Class hierarchy.

### Week 11

#### 12 April (Thursday): While Loops

[Handout]      [Presentation]
Demos
guess_num.py
game.py
hangman.py

While-loops are an alternate form of iteration. Sometimes the right iterative tool for the job will be a for-loop, sometimes it will be a while-loop. So it's good to be familiar with both!

#### 10 April (Tuesday): Subclasses and Inheritance

[Handout]      [Presentation]
Demos
shapes.py
draw_shapes.py
compare_shapes.py
shapes_no_eq_override.py
initialize.py
override.py
resolve.py

Today we learn the ins and outs of inheritance: creating classes that are subclasses of existing classes. Subclasses inherit methods from their parent classes, but they can also override these method definitions with their own definitions when appropriate.

### Week 11

#### 5 April (Thursday): SPRING BREAK

There is no class today.

#### 3 April (Tuesday): SPRING BREAK

There is no class today.

### Week 10

#### 29 March (Thursday): Using Classes Effectively

[Handout]      [Presentation]
Demos
game.py
hangman.py
careful_hangman.py
friendly_hangman.py

In previous lectures, we learned the syntax for defining classes. Today we look at the design philosophy for creating classes.

#### 27 March (Tuesday): Classes

[Handout]      [Presentation]
Demos
worker.py
simple_cs1110.py
cs1110.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.

### Week 9

#### 22 March (Thursday): More on recursion

[Handout]      [Presentation]
Demos
reverse.py
palindrome.py
person.py
family_functions.py
morefun.py
testmore.py
hilbert.py

Delving deeper into how to write a recursive function, what the call stack looks like, and a few mathematical examples.

#### 20 March (Tuesday): Recursion

[Handout]      [Presentation]
Demos
fortune.py
open_fortune.py
family.py
print_family_members.py
hanoi.py
factorial.py
fibonacci.py
memory.py
stringfun.py
teststring.py

### Week 8

#### 15 March (Thursday): Nested Lists, Tuples, and Dictionaries

[Handout]      [Presentation]

Lists can contain lists, creating two-dimensional structures. A tuple is another built-in type: an immutable sequence of values. Dictionaries are collections of key-value pairs.

#### 13 March (Tuesday): NO CLASS - open office hours

No regular class. open office hours during lecture time instead.

### Week 7

Demos
ml_quotes.py

#### 6 March (Tuesday): Iteration and For-Loops

[Handout]      [Presentation]
Demos
cs_ants.py
ants.py
roses.py
inflate.py
ints.py
writeup with more loop examples

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.

### Week 6

#### 1 March (Thursday): Lists (and Sequences)

[Handout]      [Presentation]

A list is a sequence of values that can be of any type. A list of integers could hold a student's lab grades. A list of strings would be appropriate to maintain a shopping list for a trip to the grocery store. They are extremely useful! This lecture will show you how to create and manipulate lists, as well as how to draw them.

#### 27 February (Tuesday): Memory in Python

[Handout]      [Presentation]
Demos
birthday.py
birthday_error.py
star_wars_name.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 collection of frames for all currently executing functions).

### Week 5

#### 22 February (Thursday): Conditionals and Control Flow

[Handout]      [Presentation]
Demos
dude_wheres_my_prelim.py

We talk about the difference between program structure and program flow. We 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.

#### 20 February (Tuesday): FEBRUARY BREAK

There is no class today.

### Week 4

#### 15 February (Thursday): Objects

[Handout]      [Presentation]
Demos
shapes.py
point_fns.py

We introduce the notion of objects, a new type of data. Objects allow us to go beyond writing functions to organize code and using built-in types to organize data. Objects use programmer-defined types to bundle both code and data into useful and meaningful combinations.

#### 13 February (Tuesday): Specifications and Testing

[Handout]      [Presentation]
Demos
cornell_phone.py
cornellasserts.py
name.py
name_unit_test.py

Writing functions takes a lot of practice and no one writes perfect code on the first try. That is why it is extremely important to test your functions and make sure they are working properly. We will also see why comments are more important than just notes to yourself.

### Week 3

#### 8 February (Thursday): Strings

[Handout]      [Presentation]

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

Reading: Sections 8.1, 8.2, 8.4, 8.5, first paragraph of 8.9

#### 6 February (Tuesday): Defining Functions

[Handout]      [Presentation]
Demos
height.py
simple_math.py
room_numbers.py
scope_example.py

We learn how to create our own functions and the important difference between a function call and a function definition.

### Week 2

#### 1 February (Thursday): Functions and Modules

[Handout]      [Presentation]
Demos
my_module.py
script.py
bracy_height.py

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.

#### 30 January (Tuesday): Variables and Assignments

[Handout]      [Presentation]

We introduce the notion of a variable and how an assignment statement works.
We will use the iClickers for the first time today.

### Week 1

#### 25 January (Thursday): Types and Expressions

[Handout]      [Presentation]

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