An Introduction to Programming and Computer Science with Python, Second Edition is a free, open-source Python programming textbook designed to introduce beginners to programming and fundamental computer science concepts. Written by Clayton Cafiero, the second edition was published on July 11, 2025, and was originally developed for the University of Vermont’s CS 1210 Introduction to Programming course.
The book contains approximately 530 pages and is available under a Creative Commons Attribution-NonCommercial-ShareAlike (CC BY-NC-SA) license. This makes it a useful resource for students, teachers, self-learners, and anyone looking for a free Python programming book.

Rather than focusing only on Python syntax, the textbook combines Python programming with problem-solving and computer science fundamentals. It starts with basic programming concepts and gradually introduces functions, conditions, loops, data structures, file handling, testing, exceptions, structured data, graphs, and algorithms.
What Is An Introduction to Programming and Computer Science with Python?
This book is an introductory textbook for learning programming with Python while developing a foundation in computer science.
The book is suitable for people who are new to programming because it introduces concepts progressively. Readers begin with basic Python operations and programming terminology before moving into more complex programming structures and computer science topics.
The second edition expands several areas of the original book and adds additional material, exercises, examples, and topics such as sets, JSON, additional exceptions, and other Python features.
Main Topics Covered in the Book
1. Introduction to Computer Science and Programming
The book begins with an introduction to computer science and programming. It explains the role of programming in solving computational problems and introduces fundamental ideas that students need before writing more complex programs.
Topics include programming concepts, computational thinking, algorithms, and programming languages.
2. Python Programming Basics
The book introduces Python as the primary programming language.
Readers learn about the Python Shell, basic program execution, syntax, semantics, statements, and expressions. The book also discusses concepts such as interpretation and compilation.
This section provides the foundation needed to begin writing Python programs.
3. Python Data Types and Literals
Understanding data types is essential for Python programming. The book introduces several fundamental Python types, including:
- Integers
- Floating-point numbers
- Strings
- Boolean values
- Numeric values and representation
- Literals
- Dynamic typing
Readers also learn how Python represents and works with different types of data.
4. Variables, Statements, and Expressions
The textbook explains how variables are used to store and work with information in Python.
Topics include:
- Variables
- Assignment
- Expressions
- Operators
- Arithmetic operations
- Statements
- Basic errors and exceptions
These concepts form the foundation for creating useful Python programs.
5. Python Functions
Functions are an important part of the book because they teach readers how to organize and reuse code.
This section covers:
- Defining functions
- Calling functions
- Parameters
- Arguments
- Return values
- Local variables
- Variable scope
- Free variables
- LEGB name resolution
Learning functions helps students break larger programming problems into smaller and more manageable pieces.
6. Python Programming Style
Writing code that works is only one part of programming. The book also introduces programming style and code readability.
Readers learn about:
- Naming conventions
- Code formatting
- Readability
- Organization
- PEP 8
- Good programming practices
These concepts help beginners develop better programming habits.
7. Console Input and Output
The book teaches students how Python programs interact with users.
Topics include:
input()print()- User input
- Output formatting
- Converting input into different data types
These features allow readers to create interactive programs.
8. Conditions, Comparisons, and Branching
Programs often need to make decisions. The book introduces conditional programming using Python’s branching structures.
Topics include:
ifelifelse- Comparison operators
- Boolean expressions
- Logical operators
- Conditional execution
These concepts allow programs to respond differently depending on the input or situation.
9. Program Development, Testing, and Debugging
The book also focuses on how programs are developed and tested.
Readers learn about:
- Program structure
- Incremental development
- Testing
- Assertions
- Debugging
- Problem decomposition
This is an important part of learning programming because beginners need to understand not only how to write code but also how to find and correct problems.
10. Python Sequences
The book introduces Python’s sequence types and explains how programmers can work with collections of values.
Topics include:
- Strings
- Lists
- Tuples
- Indexing
- Slicing
- Sequence operations
- Sequence methods
The second edition also expands coverage of useful operations and methods such as sorted(), split(), join(), and replace().
11. Loops, Iteration, and Iterables
Loops allow programs to perform operations repeatedly.
The book covers:
forloopswhileloops- Iteration
- Iterables
- Processing collections
- Repeated operations
Understanding loops is essential for writing programs that process large amounts of information efficiently.
12. Randomness, Games, and Simulations
The textbook uses practical examples involving randomness, games, and simulations to demonstrate programming concepts.
Readers are introduced to Python’s random functionality and learn how random values can be used in programs and simulations.
13. File Input and Output
The book introduces file handling so that Python programs can work with information stored outside the program itself.
Topics include:
- Opening files
- Reading files
- Writing files
- Processing file contents
- Working with stored data
File handling is an important practical Python skill and provides a foundation for more advanced data-processing tasks.
14. Data Analysis and Presentation
The textbook introduces basic data analysis and ways of presenting information.
Readers learn how programming can be used to process and examine data and produce useful results.
This section provides an introduction to applying Python programming to data-oriented problems.
15. Python Exception Handling
Errors are an unavoidable part of programming. The book explains how Python represents and handles exceptions.
Topics include:
- Exceptions
tryexcept- Error handling
- Different exception types
- Handling unexpected situations
The second edition expands its discussion of exceptions, including topics such as UnboundLocalError and UnicodeDecodeError.
16. Dictionaries, Sets, and Structured Data
The book introduces more advanced Python data structures, including dictionaries and sets.
It also covers structured data and JSON.
Topics include:
- Dictionaries
- Sets
- Structured data
- JSON
- Working with complex information
- Additional Python data-handling techniques
These concepts are particularly useful when working with real-world data.
17. Graphs and Algorithms
The final main chapter introduces graphs, which are an important topic in computer science.
Readers learn about:
- Graphs
- Graph representation
- Graph algorithms
- Breadth-first search
This gives beginners an introduction to algorithmic thinking and computer science concepts beyond basic Python programming.
Additional Topics in the Appendices
The book also includes appendices that extend the material covered in the main chapters.
These include:
- Glossary
- Mathematical notation
- Python
pipandvenv - File systems
- Flowcharts
- Code smells for beginners
- The call stack
- Unicode
- SQLite databases
- Code used for the cover artwork
These supplementary topics are useful for students who want to understand the programming environment and fundamental computer concepts more broadly.
What Will You Learn From This Python Book?
After working through the book and practicing the examples and exercises, readers can develop a foundation in:
- Python programming
- Programming logic
- Computational problem-solving
- Functions
- Conditional statements
- Loops
- Lists and tuples
- Strings
- Dictionaries and sets
- File handling
- Exception handling
- Testing and debugging
- Structured data
- JSON
- Basic algorithms
- Graphs
- Breadth-first search
- File systems
- SQLite databases
- Programming style and code organization
The book therefore provides more than a basic introduction to Python syntax. It combines programming practice with fundamental computer science concepts.
Who Should Read This Book?
This book is especially suitable for:
- Python beginners
- College and university students
- Computer science students
- Self-taught programmers
- Students taking an introductory programming course
- People looking for a free Python textbook
- Learners who want to understand programming fundamentals
- Anyone preparing for further computer science study
It can also serve as a reference for learners who have already started Python and want to strengthen their understanding of programming fundamentals.
Is This Book Good for Python Beginners?
Yes. One of the main advantages of the book is its gradual approach to programming. Instead of immediately jumping into advanced Python libraries or frameworks, it builds knowledge from basic programming concepts.
A beginner can progress from variables and expressions to functions, conditions, loops, data structures, files, exceptions, and algorithms.
However, completing this book does not mean that a reader will automatically be ready for every Python career path. Learners interested in web development, data science, artificial intelligence, machine learning, automation, or professional software development will need additional resources and practical projects.
Advantages of the Book
The book has several significant advantages.
Free and open source: The textbook can be accessed without purchasing a traditional programming textbook.
Beginner-focused: The material is structured around introductory programming education.
Python-based: Python is used throughout the book to teach programming concepts.
Computer science foundation: It goes beyond Python syntax and introduces algorithms, graphs, data representation, testing, and other fundamental concepts.
Practical programming: Topics such as files, exceptions, JSON, simulations, and databases help connect programming concepts to practical applications.
Updated second edition: The 2025 second edition expands the material and includes additional Python topics and exercises.
Limitations
The book is primarily an introductory programming textbook, so it is not intended to be a complete guide to advanced Python development.
It does not provide comprehensive coverage of areas such as:
- Django or Flask web development
- FastAPI
- Advanced machine learning
- Deep learning
- Advanced data science
- Professional software engineering
- Advanced object-oriented programming
- Large-scale application development
Readers interested in these areas should use this book as a foundation and then move to specialized learning resources.
Final Review
An Introduction to Programming and Computer Science with Python, Second Edition is a strong free resource for anyone who wants to learn Python programming from the beginning while also developing fundamental computer science knowledge.
Its biggest strength is the combination of Python programming, problem-solving, testing, data structures, algorithms, and computer science fundamentals. The book gradually progresses from basic Python concepts to more advanced introductory topics such as JSON, exceptions, graphs, breadth-first search, and SQLite.
For beginners and students, it can provide a solid foundation before moving into more specialized areas of programming.
If your goal is to learn Python properly rather than simply memorize Python syntax, this book is a worthwhile resource.
Free Download
The complete second edition is available legally and free from the University of Vermont.
Official book page: University of Vermont’s An Introduction to Programming and Computer Science with Python textbook page.
Free PDF: The official PDF of the second edition is available through the University of Vermont website.
Related Link:
Top 5 Data Science Books for Beginners

