CS 121 - Spring 2019

Please check back periodically. During the course of the term, I will add reading assignments, suggest study questions to help you prepare for class, and upload handouts.

If you are in section 1, then your class meets in the afternoon, and labs are on Tuesday. If you are in section 2, then your class meets in the morning and labs are on Wednesday.

Monday, January 14 Here is the syllabus, and the notes for today's class.

The goal of this course is for us to think in ways that are logical, organized and precise. We begin by considering the problem-solving procedure. In other words, the design and implementation of solutions. What is a programming language: what elements to we expect to find to help us write programs?

If you have your own computer, I recommend that you download Anaconda, which is a suite of software that includes Spyder, the system we will use for composing and running Python programs in this course.

There are two versions of the Python language: Python 2 and Python 3. Throughout this course we will use only Python 3. The two versions are not compatible, so please make sure you are running version 3.

Let's look at some very simple computer programs. What do you notice about them?

Lab #1 The lab handout is here.

The purpose of this lab is to learn how to use the Spyder environment. We will run some short Python programs, and look at mathematical operators in Python.

Wednesday, January 16

Here are the notes for the unit on basic I/O and calculations. You should read through page 7 for Wednesday's class, and page 11 for Friday's class.

Coding conventions (identifiers, comments, indenting, blank lines)
Practice reading input of numbers and text.
Formatted output, to make our output look nice.
Variables, types, expressions
Operators including /, //, % and **
Constructor functions to change a variable's type

Friday, January 18 Precedence and associativity of operators
Assignment statements
3 types of errors (syntax, run-time, logical)

Example programs: Calculating win/loss record; how long to fill a swimming pool.

Lab #2 The lab handout is here.

Let's practice a slightly longer program featuring input, basic calculations, and formatted output.

Wednesday, January 23 Here are the notes for the unit on the if statement.

Be ready to answer the practice questions on page 5 and 6. The if statement, the 6 relational operators, using the words "and" and "or".
Also take note that we need to indent the body of an if statement.

Here is your first homework assignment, due 1/31.

Friday, January 25 Be ready to answer the practice questions at the end of the handout on if statements.
How to handle multiple choice with "elif".
Monday, January 28 Here are the notes for the unit on loops.

We begin with while loops. Study the procedure for determining if a number is prime.

Lab #3 Here is the lab handout.

Let's practice the if statement and the while loop.

Wednesday, January 30 There are three types of mistakes we can make when writing a loop. What are they? Which kind do you think would be the most difficult to detect and fix? How can we reduce our chances of making loop mistakes?

Error checking of input: uses a while loop and a boolean variable

For-loops

Friday, February 1

Be ready to finish the problems on pp. 9-11 of the loop handout.

Here is your second homework assignment, due 2/8.

Monday, February 4

Nested loops

Lab #4 Here is the lab handout.

Practice the for loop

Wednesday, February 6

Break and continue

Be ready to answer the questions on p. 18.
Friday, February 8

Here are the notes for the unit on strings.

Begin our study of strings.

Monday, February 11 String functions
Be ready to discuss the questions on pages 5-6.

Here is your third homework assignment, due Monday 2/18.

Here are some review questions for Friday's test.
I didn't write solutions to the questions, but I would be happy to help you during office hours if you would like to go over your answers, or if you are stuck on any question.

Lab #5 Here is the lab handout.

Practice with strings.

Wednesday, February 13 Finish the handout on strings. See the review questions on pages 7-8.
Friday, February 15 Test #1 during our regular class time.
Monday, February 18

Here are the notes for the unit on lists.

Let's begin looking at lists in Python. If you know about strings, then a lot of what we do with lists will sound familiar to you.

Lab #6 Here is the lab handout.

Lists of numbers.

Wednesday, February 20 Pages 4-7 of the list handout.

Here is your fourth homework assignment, due 3/1.

Friday, February 22 Pages 8-11 of the list handout.
Monday, February 25 First, we'll finish the review questions at the end of the List handout.

The new topic this week is File I/O and Exception Handling. Here is the handout on the new unit.

Lab #7 File I/O
The files you need for lab can be found here.
Wednesday, February 27 File I/O examples
Friday, March 1 Exception handling. If time permits, we can also look at binary search.
Monday, March 11 Friends of the list: We will look at data types that are similar to the list in Python: dictionary, tuple and set. It turns out that lists and dictionaries are very commonly used in Python. Tuples and sets are occasionally useful. So, we will focus more of our attention on dictionaries.

Here is the handout containing notes on dictionaries, tuples and sets.

Here is your fifth homework assignment, due Friday 3/15, a short program called "warp speed".

Lab #8 Using try and except to handle exceptions.

The files you need for the lab are here.

Wednesday, March 13 Practice with dictionaries
Friday, March 15 Finish the dictionary handout.
Monday, March 18 Let's see how we can organize our code using functions. Unless a program is very short, it will probably be divided into one or more functions.

Here is the class handout on functions, containing many examples and practice problems that we will work on during the week.

Here is your sixth homework assignment, due on 3/25. An example input file that you can test your program on is example2.txt.

Lab #9 Creating simple functions.

Here is the lab handout.

Wednesday, March 20 Pages 5-8 of the function handout. Parameters and return values.
Friday, March 22 Pages 8-9 of the function handout. Practice problems.
Monday, March 25 Page 10 of the function handout. Practice problems.

Here are some review questions for test 2.

Lab #10 More practice with functions.

Here are the files you need for lab.

Wednesday, March 27 Finish function handout and test review.
Friday, March 29 Test #2 during our regular class period.
Monday, April 1 So far in the course you have been practicing the following skills:
  • Elements of the Python language.
  • Writing algorithms to solve a problem.
  • Turning an algorithm into a working program at the computer.
  • Using pre-defined functions in Python's run-time library.
During the rest of the course, we will focus most of our attention on the second skill above, developing algorithms. Along the way, we may come across a few more modules in Python's run-time library to help us. Also remember - there is usually more than one way to solve a problem. It can be helpful to consider alternative approaches.

Here are some practice problems we will discuss this week.

Lab #11 Design and implement a program with our problem-solving procedure.

The files you need for the lab are here.

Wednesday, April 3 Continue practice problems in class.

Here is your seventh homework assignment, due 4/12.

Friday, April 5 Let's do problems 6 and 9 from the practice handout.
Monday, April 8 Finish the practice problems from last week.
Wednesday, April 10 Here is a new set of practice problems.

Today in class, get into teams of 2 or 3 people. Select one of the problems to solve. You just need to explain your algorithm in English. On Friday you will present your solutions.

Lab #12 Write Python programs to solve two problems. The instructions and input files can be found here.
Friday, April 12 Continue discussing solutions to the practice problems.

Here is your eighth homework assignment, due Tuesday 4/23.

Monday, April 15 Your team should select another practice problem that hasn't been solved already.
Wednesday, April 17 Finish our discussion of the practice problems.

Here is your ninth homework assignment, due Tuesday 4/30.

Lab #13 The instructions and input files can be found here.
Wednesday, April 24 You will be given some examples of program source code. Your job is to figure out the purpose of each program. What comments should be included?

Here is the mystery code handout.

Lab #14 Practice reading source code and debugging. What does the program accomplish?

The files you need for lab are here.

Friday, April 26 Try to decipher programs 6-10 from Wednesday's handout.

During the last 10 minutes of class, you will be asked to fill out a survey about how you feel about your programming knowledge. This survey will help the CS department in our future course planning.

Monday, April 29 Let's review for the final exam.

Here are some review questions. Please look over all your previous handouts in the course for additional practice.

Thursday, May 2 Final exam at 12:00 for students in the afternoon section.
Tuesday, May 7 Final exam at 8:30 for students in the morning section.

This is also the last day I can accept late submissions of homework #9. It's based on my own deadline to turn in grades.

 

In case you would like another source to learn the Python language, here is a document I found from Cambridge University.