• Final exam study guide

  • There are two times to take the final exam:

    • Thursday, May 13, 8am-11am

    • Friday, May 14, 2pm-5pm

  • Office hours for final exam week:

    • Monday, May 10, 12pm-2pm (Charlie)

    • Tuesday, May 11, 9:30am-11am (Spencer)

    • Tuesday, May 11, 1pm-3pm (Lauri)

    • Tuesday, May 11, 3pm-5pm (Rich; on campus, weather permitting)

Course Info

Welcome to CS21. This course will introduce fundamental ideas in computer science while also teaching you how to write computer programs. We will study algorithms for solving problems and implement solutions in the Python programming language. Python is an interpreted language that is known for its ease of use. We also introduce object-oriented programming and data structures. A deeper coverage of these topics will be presented in CS 35.

This course is appropriate for all students who want to learn how to write computer programs and think like computer scientists. It is the usual first course for computer science majors and minors. Students with advanced placement credit or extensive programming experience should place out of this course and instead begin with CS31 or CS35.

Meeting Times:

All times listed are local to Swarthmore (US/Eastern time).

Section Days Time Instructor




Rich Wicentowski




Rich Wicentowski




Spencer Caplan




Spencer Caplan




Spencer Caplan




Rich Wicentowski

Lab Day Time Instructor




Charles Kazer




Charles Kazer



2:00pm- 3:30pm

Rich Wicentowski



2:00pm- 3:30pm

Charles Kazer



3:45pm- 5:15pm

Charles Kazer



8:15pm- 9:45pm

Spencer Caplan

Support Staff & Office Hours

Name Office Hours

Rich Wicentowski

Tuesday 3:30pm-5:30pm (and by appt)

Charles Kazer

Thursday 11:30am-1:30pm (and by appt)

Spencer Caplan

Thursday 5:30pm-7:00pm (and by appt)

Lauri Courtenay

Friday 11:00am-1:00pm (and by appt)

Academic Support Coordinator: Lauri Courtenay

Student assistants/Ninjas: Jack Ballou, Olivia Fey, Vlad Hes, Alice Huang, Sherry Huang, Martina Kampel, Christine Mason, Jacob Park, Xoe Porterfield, Anwyn Urquhart, Vika Zakharova


Book Cover

We will primarily be using the online book How to think like a computer scientist: Learning with Python by Elkner, Downey and Meyers.

See the Schedule for each week’s reading assignment.

Here are a few other useful online resources:

Course Goals

By the end of the course, we hope that you will have developed the following skills:

  • Given a program, be able to simulate on paper how a computer would execute the program, and show the results that would be produced.

  • Given a problem, be able to design a clear, concise, and correct pseudocode algorithm to solve it.

  • Given a pseudocode algorithm, be able to successfully implement it in Python.

  • Be able to use top-down design to sub-divide a large problem into reasonably-sized modular sub-problems.

  • Given several algorithms for solving the same problem, be able to analyze which algorithm would be more efficient in terms of running time.

  • Develop debugging and unit testing skills. Consistently use these skills while implementing programs.



Feb 11

00A: Welcome to CS21

00B: Logistics

01A: Intro to CS

01B: Using Linux

01C: Types in python

01D: Variable assignment

01E: Input/Output

01F: The 'def' keyword

Course Introduction

Lab 0: UNIX, editing


Feb 16

02A: For loops

02B: range function

02C: loops with range

Numbers, Strings, and Loops

Lab 1: First Programs

Feb 18


02D: Accumulators

02E: Accum. w/ strings


Feb 23

03A: Booleans

03B: if statements

03C: Multi-way if

Conditions and Boolean Logic

Lab 2: for loops

Feb 25

Quiz 1 Study Guide

03D: Logical operators

03E: Formatted printing


Mar 02

04A: Functions

04B: Return values

04C: Stack frames

First Functions, while Loops

Lab 3: if statements, for loops

Mar 04

04D: While loops

04E: Random library


Mar 09

05A: Input validation

05B: Boolean flags

05C: Lists vs Strings

Fruitful Functions

Lab 4: while loops, functions

Mar 11

Quiz 2 Study Guide

05D: Lists with functions

05E: Lists on the stack

05F: Mutating in functions


Mar 16

06A: Files

06B: Lists of lists

06C: Top-Down Design

Top-Down Design

Lab 5: More functions

Mar 18

06D: Flashcards TDD Part 1

06E: Flashcards TDD Part 2

06F: Flashcards implementation


Mar 23


Office Hours

  • no official class today

No lab this week

Mar 25

Spring Break


Mar 30

07A: Wheel of Fortune TDD Part 1

07B: Wheel of Fortune TDD Part 2

More Top-Down Design

Lab 6: Top-Down Design

Apr 01

Quiz 3 Study Guide

07C: WoF Stubs Part 1

07D: WoF Stubs Part 2

07E: WoF Implementation (Optional)


Apr 06

08A: Search

08B: Linear Search

08C: Algorithm Analysis


Continue Lab 6

Apr 08

08D: Binary Search

08E: Analyzing Binary Search


Apr 13

09A: Sorting

09B: Bubble Sort


Lab 7: Searching

Apr 15

Quiz 4 Study Guide

09C: Analyzing Bubble Sort

09D: Selection Sort


Apr 20

10A: Recursion

10B: Recursion on Lists


Lab 8: Sorting

Apr 22

10C: Recursion on Strings

10D: More Recursion


Apr 27

11A: Object Oriented Programming

11B: Defining classes

Classes and Objects

Lab 9: Recursion

Apr 29

Quiz 5 Study Guide

11C: More OOP

11D: Objects on the stack


May 04

12A: Cards part 1

12B: Cards part 2

More Classes and Objects

Lab 10: Defining classes

May 06

12C: Blackjack

12D: Semester Wrap-up


May 13

Alternate final exam 8am-11am Study Guide

May 14

Final exam 2pm-5pm Study Guide

Grading Policies

Grades will be weighted as follows:


Lab assignments (11 labs, approx 4% each)


Quizzes (5 quizzes, 4% each)


Final exam


Class attendance


Active class participation


Watching the videos


Attempting the video exercises before class

Grading details

Lab assignments

Typically, labs will be released on Sunday morning and due at the end of the day 10Saturday (at midnight). Labs are not always worth the same number of points, so each lab will be worth approximately 4% of your grade, though some larger labs may be worth a bit more than some of the smaller labs.

Labs typically take longer than 90 minutes to complete, so you should not expect to complete the entire lab assignment during the lab period. However, since you are in lab for 90 minutes each week, you are expected to use this time to make significant progress towards completing the lab assignment.

There are two ways that we measure this progress: asking the lab instructor and ninjas questions that help you make significant progress towards solving the lab, and demonstrating progress by turning in a "checkpoint" of what you have completed by the end of the lab period. You are not required to ask questions during lab, but we expect all students will turn in their "checkpoint" at the end of their lab session. Ten percent of the points for each lab assignment comes from demonstrating progress during the lab session.

Exam and Quizzes

Quizzes will be administered through Gradescope. They will available between 9pm on Thursday and 11am the following day. Once you start the start, you will have a limited window of time, typically 30 minutes, to complete it. Quizzes will be held every other week beginning in the third week. See the schedule for exact dates. Please look over these dates carefully and contact the professor in advance if you have any unavoidable conflicts.

There will be a final exam at the end of the semester. Details and dates will be released during the semester.

If you do not complete quizzes or exams, and do not let us know ahead of time potential conflicts, you will receive a zero for that assessment.

Please read the section on accommodations if you are in need of extra time. You must inform us of accommodations or conflicts at least 2 weeks in advance of quizzes and exams.

We encourage you to visit the ninja sessions and office hours to prepare and study for quizzes and the final exam.

Class attendance

You should attend every class. If you need to miss a class or circumstances arise that make it difficult or impossible to attend, please let us know as soon as possible. Each unexcused absence will reduce your "Class attendance" grade by 10%. If you reach 10 unexcused absences, you will receive a 0 for this portion of your grade.

Active class participation

In order to get full points in the "Active class participation", you must be a regular participant in the class. The primary way to do this is to share your attempts to solve end-of-video exercises with the rest of the class. In addition, we expect all students will share their ideas about problems posed by professors during the class. You can volunteer to share your solutions and solve in-class problems. If you do not volunteer, you should expect to get called on. If you’re someone that doesn’t like getting called on, you can volunteer!

Attempting the video exercises before class

You will be turning in your attempts to solve the video exercises. These are not graded on correctness. Rather, they are graded on effort. If the work you turn in demonstrates that you made a good-faith effort to complete the exercise, you will receive full credit for the exercise, even if it is incorrect. It is OK if you can’t solve the exercises: we will go over them in class. We will encourage you to present your exercises even when you know you didn’t get them right! Everyone can learn from seeing your progress and your thought process, even when the exercise isn’t fully completed.

Zoom Etiquette and Class Participation

As noted above, a substantial portion of your grade will be based on your class participation in Zoom. Here are some tips for making our remote class time most effective:

  • Join the Zoom meeting a few minutes early in case you have to deal with any technical difficulties.

  • Class time will be interactive with lots of discussion and questions. Please leave your camera on to facilitate interactions. Feel free to use a virtual background, if you’d like. If there are extenuating circumstances that prevent you from leaving your camera on, please contact your professor.

  • Come prepared for class with questions from the reading or videos, and be ready to share your attempts at completing the exercises assigned in the videos.

  • Please raise your hand or use the Zoom "raise hand" feature to ask a question. Don’t worry if other people have their hands up already: we want to hear what you have to say!

  • Unless you are speaking, please keep yourself muted. One fast way to unmute yourself is to hold down the space bar on your computer.

  • At times, we may ask all students to respond to a question in the chat window, or to a poll. Please respond promptly so that we can get a sense of the class consensus.

Lab Policy

This course features weekly lab assignments which are the largest component of your course grade. Lab attendance is required by all students. You must attend the lab session for which you are enrolled.

Lab assignments will typically be released on Sunday at the beginning of the week and will be due by midnight on Saturday. You are strongly encouraged to start early and to attend the ninja sessions for extra practice.

You will submit your assignments electronically using the handin21 program. You may submit your assignment multiple times, and a history of previous submissions will be saved. You are encouraged to submit your work regularly.

Late Policy

Late lab submissions are generally not accepted. However, given the remote nature of the class and the realities of the ongoing pandemic, we recognize that there may be times when you cannot complete the lab by the due date. Please contact your professor as soon as you suspect that you may need extra time. We will be flexible in working with you, but we will only grant exceptions for issues specifically related to the remote instruction format and illness. In all cases, even if you do not fully complete a lab assignment by the due date, you should submit what you have done to receive partial credit.

If you need an extension on an assignment or you are unable to attend class for two or more meetings due to a medical condition (e.g., extended illness, concussion, hospitalization) or other emergency, you must contact the dean’s office and your instructors. Faculty will coordinate with the deans to determine and provide the appropriate accommodations. Students should consult the College’s medical excuse policy.

Academic Integrity

Academic honesty is required in all your work. Under no circumstances may you hand in work done with or by someone else under your own name. Discussing ideas and approaches to problems with others on a general level is encouraged, but you should never share your solutions with anyone else nor allow others to share solutions with you. You may not examine solutions belonging to someone else, nor may you let anyone else look at or make a copy of your solutions. This includes, but is not limited to, obtaining solutions from students who previously took the course or solutions that can be found online. You may not share information about your solution in such a manner that a student could reconstruct your solution in a meaningful way (such as by dictation, providing a detailed outline, or discussing specific aspects of the solution). You may not share your solutions even after the due date of the assignment.

In your solutions, you are permitted to include material which was distributed in class, material which is found in the course textbook, and material developed by or with an assigned partner. In these cases, you should always include detailed comments indicating on which parts of the assignment you received help and what your sources were.

When working on quizzes, exams, or similar assessments, you are not permitted to communicate with anyone about the exam during the entire examination period (even if you have already submitted your work). You are not permitted to use any resources to complete the exam other than those explicitly permitted by course policy. (For instance, you may not look at the course website during the exam unless explicitly permitted by the instructor when the exam is distributed.)

Failure to abide by these rules constitutes academic dishonesty and will lead to a hearing of the College Judiciary Committee. According to the Faculty Handbook:

Because plagiarism is considered to be so serious a transgression, it is the opinion of the faculty that for the first offense, failure in the course and, as appropriate, suspension for a semester or deprivation of the degree in that year is suitable; for a second offense, the penalty should normally be expulsion.

This policy applies to all course work, including but not limited to code, written solutions (e.g. proofs, analyses, reports, etc.), exams, and so on. This is not meant to be an enumeration of all possible violations; students are responsible for seeking clarification if there is any doubt about the level of permissible communication.

The general ethos of this policy is that actions which shortcut the learning process are forbidden while actions which promote learning are encouraged. Studying lecture materials together, for example, provides an additional avenue for learning and is encouraged. Using a classmate’s solution, however, is prohibited because it avoids the learning process entirely. If you have any questions about what is or is not permissible, please contact your instructor.

Regret clause

If you commit some act that is a violation of the integrity policy (or, if you are unsure if it violates the policy) but bring it to the attention of the course’s instructors within 48 hours, the course may impose local sanctions that may include an unsatisfactory or failing grade for work submitted, but the course will not refer the matter for further disciplinary action except in cases of repeated acts.

Student Support

Lauri Courtenay is the CS Department’s Academic Support Coordinator. She will be working closely with our student mentors, also known as Ninjas, to help you learn how to program and think like a computer scientist. The CS21 Ninjas will assist us in class and run evening study sessions The CS21 Ninjas (student mentors) are: Jack Ballou, Olivia Fey, Vlad Hes, Alice Huang, Sherry Huang, Martina Kampel, Christine Mason, Jacob Park, Xoe Porterfield, Anwyn Urquhart, Vika Zakharova.

Study Sessions

You are invited — and encouraged — to participate in Ninja study sessions to prepare for quizzes, to discuss programming concepts, and to get friendly assistance in working on lab assignments. Our CS mentoring team is dedicated to helping students, who have no prior knowledge of computer science, learn to program in Python while keeping their senses of humor intact.

Weekly Ninja Sessions









All meeting times are local to Swarthmore (US/Eastern time).

Remote access using ssh

To connect to the CS machines from your dorm room or home, you will need the ssh program on your machine. ssh stands for Secure Shell. It is considered secure because all communications done through ssh are encrypted. This means anyone monitoring the network traffic will only see encrypted text going by, and not what you are actually typing (like your password).

You should follow the instructions on how to connect your machine to the CS lab. If you have any problems, please contact your professor or lab instructor!

Academic Accommodations

If you believe you need accommodations for a disability or a chronic medical condition, please contact Student Disability Services via e-mail at studentdisabilityservices at to arrange an appointment to discuss your needs. As appropriate, the office will issue students with documented disabilities or medical conditions a formal Accommodations Letter. Since accommodations require early planning and are not retroactive, please contact Student Disability Services as soon as possible. For details about the accommodations process, visit the Student Disability Services website.

To receive an accommodation for a course activity, you must have an Accommodation Letter from the Office of Student Disability Services and you need to meet with us to work out the details of your accommodation at least two weeks prior to the activity.

You are also welcome to contact us privately to discuss your academic needs. However, all disability-related accommodations must be arranged, in advance, through Student Disability Services.

How to Succeed in CS21

  • Before class: read the textbook

    Don’t worry about total comprehension, but at least get a feel for what we will be covering that week. If you have some understanding of the material before watching the videos and attending class, it will be easier for you to complete the exercises and ask questions.

  • Before class: watch videos and complete the exercises

    The primary introduction to the course material is through flipped classroom videos. We expect you to watch these videos before attending the synchronous Zoom class. Most videos end with an exercise for you to work on. You should be ready to discuss your solutions to these exercises in class. It’s important for you to attempt these exercises and come to class with questions if you are unsure how to complete them.

  • Attend synchronous Zoom class

    We will use class time for you and your peers to discuss exercises from the videos. Discussing exercises is an important part of the learning process. We will also use class time to go over more examples and cover new material.

  • Ask questions if you don’t understand

    There are lots of opportunities for you to ask questions: attending class, attending lab, office hours, and ninja sessions. This class continually builds on previous material, so if you don’t understand something one week, it will continue to be a problem the next week, and the week after that, and so on.

  • Start the lab assignments early

    Before attending lab each week, you should read through the lab assignment and begin sketching out a solution, on paper or in python. If you get stuck early (i.e., not two hours before it is due), there will be time to get help from the CS21 support staff and ninjas. In addition, starting early means you can take a break, go do something else, and come back later. We find we always have at least a few new ideas when coming back to a problem after a break.

  • Practice, practice, practice

    The only way to effectively learn the material and succeed on the quizzes and final exam is to consistently do the exercises and labs. Finish all of these programs — and do some extras, for fun! Even if you don’t get them done on time, they will still help you learn the material.

  • Attend Labs and Ninja Sessions

    Lab attendance is required. The student Ninjas hold evening study sessions each week. You are encouraged to participate in these sessions. The Ninjas will help you prepare for quizzes, will provide additional instruction in programming concepts, and will provide friendly assistance on your lab assignments.

Programming Style

Programming is not a dry mechanical process, but a form of art. Well written code has an aesthetic appeal while poor form can make other programmers and instructors cringe. Programming assignments will be graded based on style and correctness. Good programming practices usually include many of the following principles:

  • A comment at the top of the program that includes

    • Program authors

    • Date or Dates

    • A brief description of what the program does

  • Concise comments that summarize major sections of your code

  • Meaningful variable and function names

  • Function comments that include:

    1. description of what function does

    2. description of input value(s) (parameter values)

    3. description of return value

  • Well organized code

  • White space or comments to improve legibility

  • Avoidance of large blocks of copy-pasted code

Emacs Commands

When using the following commands:

  • C = control key

  • M = escape key

C-x means hold the control key while also pressing the x key, the same way you might use C-c to copy.

For commands with the escape key, just press escape and release it—​don’t hold it down.

Description Command

Starting Emacs


Quitting Emacs

C-x C-c



C-x C-s

Save As…​

C-x C-w


C-x C-f

Error recovery

Abort command


Undo a change

C-x u or C-_

Cutting and pasting

Use mouse to highlight section


DELETE highlighted text (but don’t put in clipboard)


CUT highlighted text (and save to clipboard)


COPY highlighted text (and save to clipboard)


CUT from cursor to end of line (and save to clipboard)


Paste from clipboard




Multiple windows

Terminal window in emacs

C-c s

Switch windows

C-x o

Remove other windows

C-x 1


PgDown or C-v

Down on screen

PgUp or M-v

Up on screen

M - <

Beginning of file

M - >

End of file

Links that are related to the course may be posted here. If you have suggestions for links, let us know.