CS 1210
Computer science is a science of abstraction—creating the right model for a problem and devising the appropriate mechanizable techniques to solve it.
–Alfred V. Aho
Abstraction is deliverance.
–James Brandon Lewis
Introduction to Programming
Presented here is a subset of materials for use in CS 1210 Introduction to Programming. What follows is incomplete, and subject to revision, deletion, and rearrangement.
Textbook: Cafiero, Clayton. 2023–2025. An Introduction to Programming and Computer Science with Python. ISBN: 979-8-9887092-0-6. Hard copy available in UVM Bookstore (price should be $14.00). Revision history (from first print edition forward)
Feedback, including reports of errata, criticisms, suggestions, and proposed revisions, is warmly encouraged.
Second edition in the works
The second edition of the textbook is almost done, and I expect to have it completed by August 2025. Here’s a draft (incomplete, and content subject to change): An Introduction to Programming and Computer Science with Python, Second Edition. ISBN: 979-8-9887092-1-3.
Second edition adds the following:
- expanded treatment of functions and scope, with coverage of free variables and Python’s LEGB resolution strategy;
- coverage of
UnboundLocalError
andUnicodeDecodeError
exceptions; - coverage of Python’s built-in
sorted()
- coverage of string methods
.replace()
,.join()
, and.split()
; - coverage of sequence method
.count()
; - using the keyword
is
to test for identity; - coverage of list method
.extend()
; - coverage of
random
module functions.gauss()
and.sample()
andmath
module functions.exp()
,.log()
,.log2()
,.log10()
,.floor()
,.ceil()
,.degrees()
and.radians()
; - sets;
- expanded treatment of structured data including named tuples and the
json
module; - use and abuse of the
global
keyword; - strategies for dealing with long lines and PEP 8; and
- new appendices: Code smells for beginners, An even deeper dive into functions, The joy of Unicode, and An introduction to databases with SQLite
Preliminaries
Since we’ll be writing programs in Python, you’ll need… Python!
Selections from the textbook
Here are selections from the textbook, An Introduction To Programming and Computer Science With Python, and some supplemental videos.
01: Introduction
02: Programming and the Python Shell
03: Types and literals
04: Variables, statements, and expressions
05: Functions
- Introduction
- Introduction to functions
- A deeper dive into functions
- Passing arguments to a function
- Functions (video 9:21)
- Functions with more than one parameter (video 15:35)
- Scope
- Pure and impure functions
- Pure and impure functions (video 5:00)
- The
math
module - Free variables, scope, and LEGB
- Exceptions
06: Style
07: Console I/O
08: Branching, comparisons, and conditions
09: Structure, development, and testing
10: Sequences
- Introduction
- Lists
- Tuples
- Mutability and immutability
- Subscripts are indices
- Concatenating lists and tuples
- Copying lists
- Finding an element within a sequence
- Counting elements within a sequence
- Sequence unpacking
- Strings are sequences
- More string methods
- Sequences: a quick reference guide
- The Python built-in
sorted()
- Slicing
- Passing mutables to functions
- The
global
keyword - Exceptions
11: Loops, iteration, and iterables
- Introduction
- Loops: an introduction
- Loops (video 48:43)
while
loops- An ancient algorithm with a
while
loop for
loops- Iterables
- Iterating over strings
- The list method
.extend()
- Calculating a sum in a loop
- Summations and loops (video 10:23)
enumerate()
- Tracing a loop
- Nested loops
- Stacks and queues
- A deeper dive into iteration in Python
- Slicing and sequences (video 10:03)
12: Randomness, games, and simulations
13: File I/O
14: Data analysis and presentation
15: Exception handling
16: Dictionaries and structured data
17: Graphs
Appendices
- Appendix A: Glossary
- Appendix B: Mathematical notation
- Appendix C:
pip
andvenv
- Appendix D: File systems
- Appendix E: Flow charts
- Appendix F: Code for cover artwork
- Appendix G: Code smells for beginners
- Appendix H: An even deeper dive into functions (coming soon)
- Appendix I: The joy of Unicode
- Appendix J: An introduction to databases with SQLite