Python continues to be one of the most widely used programming languages in education, software development, and data science. Its clean syntax and extensive ecosystem make it the go-to language for introductory computer science courses at universities around the world. A growing number of institutions are adopting open educational resources to provide students with free, high-quality learning materials that can be adapted to different curricula.
In this landscape, having access to a well-structured, modern textbook that covers both programming fundamentals and computer science concepts is essential for self-learners and students alike. The second edition of this textbook from the University of Vermont meets that need with updated content and a practical approach tailored to beginners.
About the book
An Introduction to Programming and Computer Science with Python, second edition is a free, open source textbook developed for UVM’s CS1210 Introduction to Programming course. It covers the basics of programming using Python, from fundamental concepts like variables and control flow to more advanced topics including data structures, file I/O, exception handling, and introductory computer science concepts such as graph search algorithms.
The book assumes no prior programming experience. It starts with the most basic concepts and builds up gradually, making it suitable for complete beginners. Each chapter includes exercises and comprehension checks to reinforce learning. The second edition adds expanded coverage of functions and scope, string methods, sets, structured data with JSON, and new appendices on code smells, the call stack, Unicode, and SQLite.
What you will learn
- Write and run Python programs using the interactive shell and script files
- Work with variables, data types, expressions, and operators
- Use functions, understand scope, and apply Python’s LEGB resolution strategy
- Write clear, well-structured code following Python style conventions
- Handle console input and output with formatted strings
- Implement branching logic with conditionals and Boolean expressions
- Use sequences, lists, tuples, and strings effectively
- Iterate with while and for loops over iterables
- Read from and write to files using context managers
- Work with randomness for simulations and games
- Analyze data with basic statistics and visualizations using Matplotlib
- Handle exceptions properly in your programs
- Use dictionaries, sets, named tuples, and JSON for structured data
- Implement graph algorithms including breadth-first search
Table of contents
- 1. Introduction
- 2. Programming and the Python shell
- 3. Types and literals
- 4. Variables, statements, and expressions
- 5. Functions
- 6. Style
- 7. Console I/O
- 8. Branching, comparisons, and conditions
- 9. Structure, development, and testing
- 10. Sequences
- 11. Loops, iteration, and iterables
- 12. Randomness, games, and simulations
- 13. File I/O
- 14. Data analysis and presentation
- 15. Exception handling
- 16. Dictionaries, sets, and structured data
- 17. Graphs
Appendices: Glossary, Mathematical notation, pip and venv, File systems, Flow charts, Code for cover artwork, Code smells for beginners, The call stack, The joy of Unicode, A brief introduction to databases with SQLite
Book details
- Title: An Introduction to Programming and Computer Science with Python, second edition
- Author(s): Clayton Cafiero
- Publication year: 2025
- Publisher: University of Vermont
- Pages: 520
- PDF size: 6.4 MB
- Estimated reading time: ~13 h 0 min
- Level: Beginner
- Main category: Programming
- Subcategory: Python
- Language: English
- License: CC BY-NC-SA 4.0
More books in: Programming, Python
Legal notice: This book is shared for educational purposes only. The content is distributed under Creative Commons licenses or with explicit permission from the author. FreeProgrammingBooks may host files that comply with their respective licenses.