MPCS 51042 - Python Programming
Python is one of the most commonly used programming languages today across a huge range of sectors. It is a language designed to be easy to learn that emphasizes readable code via powerful and extensible syntax. This course provides a thorough overview of the Python language with an emphasis on writing idiomatic code.
This course aims to:
- Build general-purpose programming skills. From thinking about decomposing problems into parts to thoughtful choices of data structures and algorithms.
- Emphasize Python’s strengths as a multi-paradigm language by exploring procedural, functional, and object-oriented styles.
- Introduce the powerful ecosystem of Python libraries, and encourage continued growth as a Python programmer.
This course will cover:
- Python Basics: types, variable, operations, control flow, iteration
- Functions: including scope rules, functional programming constructs, recursion, and generators
- Object-Oriented Programming in Python: classes, dynamic attributes, operators
- Data structures in Python (lists, stacks, hash tables, queues, trees)
- Modules, packages, and the broader Python ecosystem
- A brief introduction to scientific computing in Python
Quick Links
- Lecture Notes
- Course Policies - Academic Honesty, AI, Accessibility, Code of Conduct, Diversity, Late, and Regrade policies.
- Common Grade Deductions
- Getting Help
- Using uv
- Using pytest
- CS Student Resource Guide
Readings
While there are no required textbooks for this course, I provide suggested readings from the following books.
I’d highly recommend picking up one of these, there is no need to get both:
- Python Distilled (1st Edition), by David Beazley
- Learning Python (5th Edition), by Mark Lutz
Additionally, these books may be useful to further explain concepts discussed in this course:
- Fluent Python (2nd Edition), by Luciano Ramalho (1st Edition OK)
- Python in a Nutshell (3rd Edition), by Martelli, Ravenscroft, and Holden
Office Hours
Regular office hours start Week 2, unless otherwise indicated.
| Who | Where | When |
|---|---|---|
| Summer Han | JCL 207 | Monday 9:00-11:00am |
| Pablo Hernandez Pedraza | JCL 207 | Tuesday 3:30-4:30pm |
| Keling Yue | JCL 205 | Wednesday, 10:00am-noon (starting Week 3) |
| James Turk | JCL 398E | Wednesday 2:00-4:00pm |
| Stanley Yi | JCL 205 | Thursday 9:00-11:00am |
| Pablo Hernandez Pedraza | JCL Common Area 3A | Thursday 3:30-4:30pm |
| James Turk | Zoom | Friday, 11am-1pm |
!!! note
James also has openings for appointments available: <https://cal.com/jamesturk/autumn-office-hours>
Please note that these are limited and they are shared between multiple classes, so please be considerate in your usage and favor the drop-in office hours for help on assignments.
Schedule
Meets Tuesday & Thursday 11:00am-12:20pm @ JCL 011.
Any schedule changes will be announced in class and on Ed Discussion.
| Week | Topics | Assignment | Resources & Readings * | |
|---|---|---|---|---|
|
1 Sep. 29-Oct 3 |
Python Basics
|
Homework #0 Out |
Python Distilled Ch. 1-3.3 Learning Python Ch. 1-7, 12, 13, 16 Python Tutorial Parts 1-4.5 |
|
|
2 Oct 6-10 |
Python Basics (Part 2)
|
Homework #0 Due Oct 10 @ 11:59pm CT Homework #1 Out |
Python Distilled Ch. 4.1-4.5, 5.1-5.10, 9.6-9.12 Learning Python Ch. 8, 9 Python Tutorial Parts 5, 7 |
|
|
3 Oct 13-17 |
Advanced Functions
|
Homework #1 Due Oct 17 @ 11:59pm CT Homework #2 Out Quiz #1 - Oct 16 |
Python Distilled Ch. 5-6 Learning Python Ch. 14, 17-20, 39 Python Tutorial Part 4 |
|
|
4 Oct 20-24 |
Comprehensions, Generators, Decorators
|
Homework #2 Due Oct 24 @ 11:59pm CT Homework #3 Out |
Python Distilled Ch. 8, 10 Learning Python Ch. 22-24 Python Tutorial Part 6, 10-12 |
|
|
5 Oct 27-Oct 31 |
Object Oriented Programming
|
Homework #3 Due Oct 31 @ 11:59pm CT Homework #4 Out |
Python Distilled Ch. 7 Learning Python Ch. 26-28 Python Tutorial Part 9.1-9.4 |
|
|
6 Nov 3-7 |
Advanced Classes
|
Homework #4 Due Nov 7 @ 11:59pm CT Homework #5 Out Quiz #2 - Nov 4 |
Python Distilled Ch. 7 Learning Python Ch. 29, 31, 32 Python Tutorial Part 9.5 |
|
|
7 Nov 10-14 |
Python Data Model
|
Homework #5 Due Nov 14 @ 11:59pm CT Homework #6 Out |
Python Distilled Ch. 3.4-3.7, 4 Learning Python Ch. 30, 32-36, 38 Python Tutorial Part 8 |
|
|
8 Nov 17-21 |
Python Packages & Ecosystem
|
Homework #6 Due Nov 21 @ 11:59pm CT |
Python Distilled Ch. 9.15, 10 Python Tutorial Part 10-12 |
|
| Nov 24-28 | Thanksgiving Break | |||
|
9 Dec 1-Dec 5 |
Special Topics
|
Quiz #3 - Dec 2 |
||
|
10 Dec 8-12 |
No Class |
Final Project Final Exam TBD |
||
Programming Assignments
There will be seven programming assignments and a final project.
!!! note
For planning purposes, it may be helpful to know Homework #0 and #6 are shorter than the rest.
All programming assignments in this course will be distributed via GitHub Classroom and submitted via Gradescope.
Checking Out an Assignment
When an assignment is made available a link to GitHub classroom will be posted on Ed. Clicking the link will create a new private repository for the assignment.
Once the repository is created, you will want to clone the repository to your machine.
Visit your repository on GitHub, and click on the green “Code” button. Be sure SSH is selected as pictured. Copy the URL to the repository.

To check out your project, you can run
git clone <URL>from the machine you’re doing your work on.Once the assignment is checked out, the first step will be
uv sync, this will ensure you have the appropriate packages downloaded for the assignment.Each assignment has a README.md, this contains the full description of the assignment. It is recommended you read all the way through before beginning, careful reading of requirements is a skill being practiced in this class.
Working on an Assignment
General Tips
Install dependencies. Once the assignment is checked out, first run
uv sync. This will ensure that you have the necessary packages for this project, details will be discussed in class.Read the instructions carefully - Make sure you understand what you’re being asked to do before you start writing code. If you’re not sure, ask for clarification.
Check in often - Check your code into git and push to GitHub regularly. This will help you avoid losing work if something goes wrong with your machine.
Run the tests - The tests are there to help you. If you’re not sure if your code is correct, run the tests and see if they pass. If they don’t, read the error messages carefully - they may give you a hint as to what’s wrong.
Experiment in the REPL - If you’re not sure how a particular function or method works, try it out in the REPL (
python3oripython). A major advantage of interpreted languages is this ability to experiment interactively.Ask questions of course staff - If anything is not clear, ask questions via Ed! If you are stuck or need help with a concept, office hours may be a good idea as well! See Getting Help for more advice on how to ask for help.
Use a Linter.
ruffwill be introduced and is recommended. Using it (or a linter of your choice) in this course will let you focus on the actual problem, help you write cleaner code, and detect common issues that may result in a lower grade.
pytest Tips
Each assignment comes with a set of tests to be run with pytest.
(If you are using uv, remember to prefix all pytest commands with uv run!)
pytest has some helpful command line options you may wish to use:
- Passing a filename like
tests/test_markov.pywill run only the tests in that file. -vwill print out more information about each test-vvwill print out even more information about each test, particularly useful when comparing expected output vs. actual-swill include any output fromprintstatements (normally suppressed bypytest).-k <pattern>will only run tests whose names match the pattern. (Sopytest -k frontendwould matchtest_frontend_templateandtest_frontend_callbut nottest_database_setup, etc.)-xwill stop running tests after the first failure.
Grading
We will be using specifications grading in this course. The goal of specifications grading is to help students focus on their mastery of the material and identify areas for improvement as the quarter progresses.
Shorthand: focus on skills, not scores.
If you are new to using specifications grading, here’s what you can expect:
- For each assignment you will be given a set of specifications. Meeting all/most of those will earn the highest grade. This is described in detail below, but aims to allow you to focus on learning and not on the difference between an 89 and a 90 on an assignment. It also more closely resembles how work is evaluated in the real world, where work is either satisfactory or not.
- Where time permits, we will allow resubmissions of work to learn from mistakes. The specific policy is detailed below.
SNU Scale
Programming Assignments will be evaluated using an SNU scale:
Satisfactory (S): While the work has some room for improvement, the student has put in a good-faith effort to complete all the work and demonstrated sufficient mastery of the material.
Needs Improvement (N): The student has put in a good-faith effort to complete the work, but revealed a lack of mastery in the material that can be addressed via concrete feedback. The work could become Satisfactory with some major revisions.
Ungradable (U): The student did not submit any work, or did not complete a sufficient portion of the work to be graded.
All assignments will be evaluated for completeness and code quality, and given a grade for each.
Completeness will be determined using an automated test suite. “Does your code do what we asked of it?”
Code quality will be evaluated by reviewing the code for:
- adherence to the style guide
- appropriate choice of algorithms and data structures
- appropriate use of functions and classes to structure the computation.
Resubmissions
You will be allowed to resubmit one programming assignment (not the project).
Once a programming assignment is graded and returned to you, there will be a two week window for you to resubmit that assignment. This means that, if you produce work that needs some improvement, you will have a chance to address the grader’s feedback to improve your score on that assignment.
The procedure for resubmissions will be shared via Ed.
Mastery Quizzes
There are three “mastery quizzes”, these quizzes serve two purposes:
Give you a chance to practice on the kinds of questions on a paper programming exam. (for this final, or certain interviews)
Allow you to ensure that you are retaining the important concepts, and not overly relying on StackOverflow/GPT/etc. when solving problems.
Each mastery quiz will be scored out of 30-40 points.
These scores are for primarily your own benefit, there is no penalty for doing poorly or even not taking the quizzes. Make-ups will only be available in exceptional circumstances.
If you get more than 90% of the available points, you have demonstrated mastery of the subjects at hand and will waive that third of the exam.
If you do not receive above 90% on any portion, you may elect to use one of your quiz grades as a substitute for that portion of the exam. (See Example 2 below.)
Final Exam
The final exam will be given in Week 10/finals week. It will scored out of 100 points, and will cover all topics from the course. It will be made up of three parts, corresponding to the three mastery quizzes.
As mentioned, you may opt to take only some portions of it (or skip it altogether) depending on your performance on the quizzes and desired final grade.
Example 1
- Quiz #1: 28/30 (93%)
- Quiz #2: 20/35 (57%)
- Quiz #3: 30/35 (86%)
This student has demonstrated mastery on the topics covered by Quiz #1, and will not need to take that portions of the final exam.
They take the final exam:
- Part 1: Waived/30
- Part 2: 32/35
- Part 3: 29/35
Their final exam score is 30+32+29 = 91.
Example 2
- Quiz #1: 20/30 (66%)
- Quiz #2: 14/35 (40%)
- Quiz #3: 27/35 (77%)
First, this student did not perform poorly!
The mastery quizzes are given quickly after content is introduced, and if it is new to you (which is the hope for most people in this course!) you are unlikely to have already fully digested it.
Instead this student can recognize that the material covered on Quiz 2 is their weakest, and plan accordingly.
They take the final and do much better, having now seen the kinds of questions that may be asked and focusing on the ones they struggled with:
- Part 1: 28/30
- Part 2: 35/35
- Part 3: 26/35
Their grade went up significantly in Part 1 and 2. Part 3 they did a point worse than the quiz on, but overall a marked improvement.
Their final grade here would be: 28 + 35 + 27 = 90.
The 27 is used from their Quiz 3 instead of their slight decrease in Quiz 2.
(This will only be done for one section, you may opt to use this rule to skip a single section of the final if you wish to focus your efforts on two others and accept a sub-90% quiz grade instead.)
Example 3
- Quiz #1: missed (0%)
- Quiz #2: 34/35 (97%)
- Quiz #3: 34/35 (97%)
This individual has earned a 70 on the exam without even taking it (full credit for parts 2 and 3). Depending on what they need for the final grade they want, they may decide to take Part 1 of the final, or skip it altogether.
Final Grade
Your final grade will be determined by 18 programming grades (14 from the 7 assignments, and 4 from the project) and your final exam score.
| Assignment Type | Number | When |
|---|---|---|
| Programming Assignment | 7 | Weeks 1-7 |
| Programming Project | 1 | Weeks 8-10 |
| Quizzes | 3 | Weeks 3, 6, 9 |
| Final Exam | 1 | Week 10 |
Your final grade is a function of three variables:
- S the total number of S grades you received.
- U the maximum number of U grades you received.
- T Your exam/quiz total, which will be between 0-100.
| S >= | U <= | 50 <= T < 70 | 70 <= T < 80 | 80 <= T < 90 | T > 90 |
|---|---|---|---|---|---|
| 16 | 0 | B | B+ | A- | A |
| 14 | 2 | B- | B | B+ | A- |
| 12 | 3 | C+ | B- | B | B+ |
| 10 | 4 | C | C+ | B- | B |
| 9 | 5 | C- | C | C+ | B- |
| 8 | 6 | D+ | C- | C | C+ |
- If you have 16 S, 2 N, 0 U: then you are in the top row. A 90 on the exam will earn you an A.
- If you miss an assignment entirely and earn 2 U, but have at least 14 S: you are in the second row. A 80 on the exam would earn you an B+ overall.
Anything lower than what is represented in the chart will need to be addressed on a case-by-case basis.
Remember: A C+ is a passing grade for MPCS courses.
Academic Honesty Violation
The minimum penalty for an academic honesty violation is a U on for all grades on the assignment in question and having the highest grade you can earn in the class capped at a B.
You may not use a regrade on an assignment flagged for an academic honesty violation.
There will be no exceptions to this policy.
Curving
In lieu of traditional curving, I reserve the right to lower the thresholds for each grade.
I will not raise the thresholds. (So if you earn an A- according to the above chart, you will get an A- or better.)