Computer Programming with Python

Computer Programming with Python M 20 P (Fall 2025 @ UCLA)

An introduction to computer programming and computational thinking with a focus on the Python 3 language. The course starts from first principles—variables, branching, loops—and advances to object-oriented design, algorithmic efficiency, and practical software engineering techniques such as testing and debugging. Key programming concepts include basic data types, control structures, input/output, functions, recursion, and object-oriented programming with an emphasis on Python-based data structures, writing efficient, modular code and testing/debugging techniques.

Examples and exercises are drawn from engineering, mathematics, and the physical sciences to ground abstract concepts in real-world problem solving. Instruction blends mini-lectures, live-coding sessions, and hands-on exercises to ensure students leave each class with runnable code and a clear mental model of how it works. Time permitting, a brief module on ethics, reproducibility, and responsible AI/tool use will be included.

Course Logistics

  • Instructor: Dr. Shahriar Talebi, s.talebi@ucla.edu
  • , office: Eng IV, 38-137F
  • Teaching Assistant: Yasamin Foroutani, yforoutani@g.ucla.edu
  • Office Hours: TBA | Zoom
  • Structure & Workload:
    Lecture · 2 h / week | Discussion · 2 h / week | Laboratory · 2 h / week | Outside study · ≈ 6 h / week
  • Prerequisite: Mathematics 33A
  • Grading: Letter
  • Class Time: Thursdays 4pm-5:50pm & Wednesdays 8am-9:50am
  • Class Location: Kinsey Science Teaching Pavilion 1220B (in person)
  • Laboratory Time: Thursdays 4pm-5:50pm & Wednesdays 12pm-1:50pm
  • Laboratory Location: Boelter Hall 4404

Course Websites

Main Texts & References

  1. Think Python (3rd ed.) – Allen Downey (Free Online)
  2. Introduction to Computation & Programming Using Python – John Guttag

Other Texts & Broader references (Mostly Free Online)

  1. How to Solve It - George Pólya (Read this summary!)
  2. Numerical Methods in Engineering with Python - Jaan Kiusalaas
  3. Python Data Science Handbook (2nd ed.) – Jake VanderPlas
  4. Introduction To Computer Science And Programming In Python - MIT OpenCourseWare

Course Schedule (Tentative)

Date Topic Lab Exercises
(Think Python 3e)
Prerequisite Lecture notes/slides* Resources / Extra Reading
Week 1 Course logistics • Programming mindset
Syntax, variables, types, operators, Basic I/O, code style
Variables & control-flow drill + mini-debug (pdb watch-list) Numerical tie-in: NumPy warm-up: Gaussian elimination; condition number & least-squares Ch 01 & 02 Math 33A Guttag Ch 1 ; Kiusalaas Ch 1
Python tutorial (official),
PEP 8 style guide,
Turing Machine,
Bitwise Operators in Python
Week 2 Branching and conditionals, loops, ranges; Comparison/Boolean Operators; Data structures: lists, tuples; list comprehensions Array exercises • Loop-based problem solving (max, sum, reverse) • Off-by-one error debugging
Numerical Methods: Systems of linear algebraic equations
Ch 06 (Iteration)  + Ch 08 (Lists)
§03.12 list-comprehension *peek*
Basic program structure Guttag Ch 2–3; Kiusalaas Ch 2
LearnPython.org interactive
Real Python • Loops
Python docs – lists & tuples
Week 3 Functions, scopes, *args/**kwargs, iterables, map, lambda function • Testing mindset (assertions & pytest)
Modular design • Unit tests with pytest (assert patterns, simple fixtures) • Pair-programming warm-up • Numerical Methods: Interpolation and curve fitting Ch 03 (Functions) & Ch 05 §5.1-5.4 (Fruitful funcs)
*Skip recursion parts until L6*
Branching & loops Guttag Ch 4 & 8; Kiusalaas Ch 4
Real Python • Defining functions
*args & **kwargs explained
Python docs – __main__
pytest intro
Week 4 Recursion & problem decomposition • Sorting (built-in & custom) • Searching (linear / binary) • Big-O basics
Sort/search challenges + timing decorator (simple profiler) + Matplotlib multi-plot demo • Numerical Methods: Roots of equations (bisection, Newton) Ch 05 §5.5-5.9 (Recursion) & Ch 13 §13.3-13.6 (Search & Selection) Dictionaries & files Guttag Ch 11, 14–15; Kiusalaas Ch 3
Big-O Cheat Sheet
Visual Algo • Search animations
GfG sorting/search practice
Week 5 Dictionaries, sets, mutability vs hashability • Hash-based problem solving (freq maps, memoization)
Strings review • Anagrams & hashmap puzzles (with logging) • (problem selection & spec) Numerical Methods: Numerical differentiation: finite differences; error vs. step-size Ch 07 (Strings review) & Ch 09 (Dictionaries)
Ch 10 §10.2-10.4 (Tuples vs lists)
Functions & testing Guttag Ch 5 & 7; Kiusalaas Ch 5
Python Tutor visualizer
Real Python • Dictionaries
Real Python • Sets
Week 6 File I/O (text, CSV, JSON) • Script execution (if __name__ == "__main__") • Modules & packages • Defensive programming (try/except, assertions, basic debugging)
File parsing + input validation + Unit testing (pytest markers) • Tooling: VS Code/PyCharm, venv, Git/GitHub
Numerical Methods: Numerical integration: trapezoidal/Simpson; error vs. step-size
Ch 11 (Files & Exceptions) & Ch 12 (Modules) Sequences overview Guttag Ch 6, 8–9; Kiusalaas Ch 6
Automate the Boring Stuff – Ch 10-11
Real Python • File I/O
Matplotlib getting started
NumPy linalg guide
VS Code • Python
Python venv
Git docs
Week 7 OOP I: Classes, constructors, encapsulation, __str__/__repr__; Data Structures I (stacks/queues/heap)
Stack/queue/heap drills + class-based simulation (with doctest) • Structured code review via GitHub PRs • Numerical Methods: Initial value problems (ODEs): Euler & RK4; compare with scipy.integrate.solve_ivp; stability & step-size Ch 14 & 15 (Classes & Objects) Recursion & complexity Guttag Ch 10 & 13; Kiusalaas Ch 7
heapq docs
Real Python • Stacks & Queues
LeetCode stack practice
Week 8 OOP II: Inheritance, polymorphism, abstract base classes • Graphs (adjacency lists, DFS/BFS, shortest path) • DP intro
Graph problems (maze reachability, shortest path) + inheritance refactor • • Interpolation & curve fitting (NumPy/SciPy; OOP wrapper; residuals) • Numerical Methods: Two-point boundary value problems: shooting/finite differences Ch 17 (Inheritance) & Ch 18 §18.1-18.3 (Simple DP) OOP concepts Guttag Ch 12 & 15; Kiusalaas Ch 8
NetworkX docs
Khan Academy • Graph intro
CP-Algorithms • Graph guide
Week 9 Testing & Debugging Deep-Dive: pytest fixtures, coverage, pdb, logging config, profiling; Exception hierarchies, input validation; Ethics & reproducibility
End-to-end debugging workflow on prior homework • Responsible tool/AI usage caselets • Numerical Methods: Symmetric matrix eigenvalue problems: power iteration & Rayleigh quotient, compare with numpy.linalg.eig Appendix B (Debugging) & Ch 11 §11.4 (try/except) Algorithm analysis Guttag Ch 8–9; Kiusalaas Ch 9
pdb tutorial (Real Python)
Logging How-To
pytest usage guide
ACM Code of Ethics
Week 10 Capstone: Data analysis pipeline, advanced visualization (Matplotlib), intro ML (scikit-learn glimpse) • Project wrap-up & interview-style review
Pandas + NumPy project support (CSV → DataFrame); mock tech-interview round-robin Numerical Methods: Introduction to optimization: gradient descent & scipy.optimize.minimize Ch 19 (Case study: Data analysis) All prior material Guttag Ch 23–26; Kiusalaas Ch 10
Pandas intro tutorials;
scikit-learn basic tutorial;
Real Python • Data science pipeline;
Integrate Python in MATLAB (Cheat Sheet)

*Lecture slides will be available on the course website as we progress through the course. Part of the lecture materials are adapted from the cited references above.

*Slides may not cover everything discussed in class.

Course Milestones

  • Exercises ~2 Jupyter Notebooks/week: due Wednesdays 11:59 pm PT.
  • Problem Sets ~1 problem set/week: due Tuesdays 11:59 pm PT.
  • Final Project: Proposal (Week 8), Checkpoint (Week 9), Final (Finals week, date TBA).

Grading Policy

  • Weekly Problem Sets (~1 problem set/week)40 %
    Released each Wednesday, due the following Tuesday at 11:59 pm PT — Canvas submission.
  • Exercises15 %
    The completed and compiled Jupyter notebook (including the exercises) — Canvas submission. Due the midnight before each class (Wednesdays 11:59 pm PT).
  • Check-in Quizzes & Participation15 %
    Quiz based on last lecture. Attendance, discussion, Piazza/Ed posts, peer-citation, and structured peer code reviews.
  • Final (Individual) Capstone Project30 %
    (1) Analysis, (2) simulation, and (3) code documentation. Proposal & checkpoint required. Collaborations on data collection/design discussion encouraged, but code must be individual unless otherwise specified — Canvas submission.

Letter-grade bands: A ≥ 93, A- ≥ 90, B+ ≥ 87, B ≥ 83, B- ≥ 80, C+ ≥ 77, C ≥ 73, C- ≥ 70, D ≥ 60, F < 60.

Late Policy: You have 3 late-day tokens for the quarter. You may apply up to 2 tokens to any single problem set or exercise (each token = 24 hours). Tokens may not be used for quizzes, the midterm, or the capstone final deliverable unless explicitly allowed. Beyond tokens, late submissions are not accepted. If you anticipate any other issues, contact me at least 48 hours before the deadline to discuss.

Collaboration & Academic Integrity: Discuss concepts freely; all submitted code and write-ups must be your own (or your team’s, when team work is explicitly permitted). You must follow the instructions provided for each activity, specifically whether the use of AI is allowed or not. You must precisely cite any external resources or generative-AI assistance (what you used and how). Follow PEP8 and course style guidelines. Reproducibility matters: include clear instructions for setup (venv), running tests, and reproducing results.

Syllabus PDF