
Introduction to Python Programming
by Udayan Das, Aubrey Lawson, Chris Mayfield and Narges Norouzi
Published by OpenStax
Introduction to Python Programming provides a comprehensive foundation in programming concepts and skills, and it is aligned to the scope of most introductory courses. A wide array of scenarios, contexts, and problems reflect programming applications in many disciplines and careers. The offering is suitable for a diverse learner audience, including those pursuing computer science, business, science, social science, statistics, data science, and related areas of study and employment. Introduction to Python Programming is an interactive offering that teaches basic programming concepts, problem-solving skills, and the Python language using hands-on activities. The resource includes a unique, integrated code runner through which students can immediately apply what they learn to check their understanding. Embedded videos, critical thinking exercises, and explorations of external programming tools and activities all contribute to a meaningful and supportive learning experience.
Adopted pages stay linked to the book. Make your own copy of any page to change it for your class.
Attribution
Adapted from Introduction to Python Programming by Udayan Das, Aubrey Lawson, Chris Mayfield, and Narges Norouzi, published by OpenStax (Rice University) under CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/). Access the original for free at https://openstax.org/details/books/introduction-python-programming. Changes: converted to CuraCourse lessons, with interactive practice added.
Table of contents
115 pages in 16 modules. Sign up to read and adopt them.
Preface1 page
- Preface
1Statements10 pages
- Introduction
- 1.1Background
- 1.2Input/output
- 1.3Variables
- 1.4String basics
- 1.5Number basics
- 1.6Error messages
- 1.7Comments
- 1.8Why Python?
- 1.9Chapter summary
2Expressions10 pages
- Introduction
- 2.1The Python shell
- 2.2Type conversion
- 2.3Mixed data types
- 2.4Floating-point errors
- 2.5Dividing integers
- 2.6The math module
- 2.7Formatting code
- 2.8Python careers
- 2.9Chapter summary
3Objects7 pages
- Introduction
- 3.1Strings revisited
- 3.2Formatted strings
- 3.3Variables revisited
- 3.4List basics
- 3.5Tuple basics
- 3.6Chapter summary
4Decisions9 pages
- Introduction
- 4.1Boolean values
- 4.2If-else statements
- 4.3Boolean operations
- 4.4Operator precedence
- 4.5Chained decisions
- 4.6Nested decisions
- 4.7Conditional expressions
- 4.8Chapter summary
5Loops7 pages
- Introduction
- 5.1While loop
- 5.2For loop
- 5.3Nested loops
- 5.4Break and continue
- 5.5Loop else
- 5.6Chapter summary
6Functions8 pages
- Introduction
- 6.1Defining functions
- 6.2Control flow
- 6.3Variable scope
- 6.4Parameters
- 6.5Return values
- 6.6Keyword arguments
- 6.7Chapter summary
7Modules7 pages
- Introduction
- 7.1Module basics
- 7.2Importing names
- 7.3Top-level code
- 7.4The help function
- 7.5Finding modules
- 7.6Chapter summary
8Strings7 pages
- Introduction
- 8.1String operations
- 8.2String slicing
- 8.3Searching/testing strings
- 8.4String formatting
- 8.5Splitting/joining strings
- 8.6Chapter summary
9Lists7 pages
- Introduction
- 9.1Modifying and iterating lists
- 9.2Sorting and reversing lists
- 9.3Common list operations
- 9.4Nested lists
- 9.5List comprehensions
- 9.6Chapter summary
10Dictionaries7 pages
- Introduction
- 10.1Dictionary basics
- 10.2Dictionary creation
- 10.3Dictionary operations
- 10.4Conditionals and looping in dictionaries
- 10.5Nested dictionaries and dictionary comprehension
- 10.6Chapter summary
11Classes7 pages
- Introduction
- 11.1Object-oriented programming basics
- 11.2Classes and instances
- 11.3Instance methods
- 11.4Overloading operators
- 11.5Using modules with classes
- 11.6Chapter summary
12Recursion7 pages
- Introduction
- 12.1Recursion basics
- 12.2Simple math recursion
- 12.3Recursion with strings and lists
- 12.4More math recursion
- 12.5Using recursion to solve problems
- 12.6Chapter summary
13Inheritance7 pages
- Introduction
- 13.1Inheritance basics
- 13.2Attribute access
- 13.3Methods
- 13.4Hierarchical inheritance
- 13.5Multiple inheritance and mixin classes
- 13.6Chapter summary
14Files7 pages
- Introduction
- 14.1Reading from files
- 14.2Writing to files
- 14.3Files in different locations and working with CSV files
- 14.4Handling exceptions
- 14.5Raising exceptions
- 14.6Chapter summary
15Data Science7 pages
- Introduction
- 15.1Introduction to data science
- 15.2NumPy
- 15.3Pandas
- 15.4Exploratory data analysis
- 15.5Data visualization
- 15.6Summary