Want to learn the Python language without slogging your way through how-to manuals? With Head First Python, you'll quickly grasp Python's fundamentals, working with the built-in data structures and functions. Then you'll move on to building your very own webapp, exploring database management, except
Think Python, 3rd Edition (Third Early Release)
β Scribed by Allen B. Downey
- Publisher
- O'Reilly Media, Inc.
- Year
- 2023
- Tongue
- English
- Leaves
- 363
- Edition
- 3
- Category
- Library
No coin nor oath required. For personal study only.
β¦ Synopsis
Python is an excellent way to get started in programming, and this clear, concise guide walks you through Python a step at a timeβbeginning with basic programming concepts before moving on to functions, data structures, and object-oriented design. This revised third edition reflects the growing role of large language models (LLMs) in programming and includes exercises on effective LLM prompts, testing code, and debugging skills.
With this popular hands-on guide at your side, you'll get
A grounding in the syntax and semantics of the Python language
A clear definition of each programming concept, with emphasis on clear vocabulary
How to work with variables, statements, functions, and data structures in a logical progression
Techniques for reading and writing files and databases
A solid understanding of objects, methods, and object-oriented programming
Debugging strategies for syntax, runtime, and semantic errors
An introduction to recursion, interface design, data structures, and basic algorithms
How to use LLMsβincluding effective prompts, testing code, and debugging
And more
β¦ Table of Contents
Preface
Who Is This Book For?
Goals of the Book
Navigating the Book
Whatβs new in the third edition?
Getting started
Resources for Teachers
Conventions Used in This Book
Using Code Examples
OβReilly Online Learning
How to Contact Us
Acknowledgments
1. Programming as a way of thinking
Arithmetic operators
Expressions
Arithmetic functions
Strings
Values and types
Formal and natural languages
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
Exercise
2. Variables and Statements
Variables
State diagrams
Variable names
The import statement
Expressions and statements
The print function
Arguments
Comments
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
3. Functions
Defining new functions
Parameters
Calling functions
Repetition
Variables and parameters are local
Stack diagrams
Tracebacks
Why functions?
Debugging
Glossary
Exercises
Ask an assistant
Exercise
Exercise
Exercise
Exercise
4. Functions and Interfaces
The jupyturtle module
Making a square
Encapsulation and generalization
Approximating a circle
Refactoring
Stack diagram
A development plan
Docstrings
Debugging
Glossary
Exercises
Exercise
Exercise
Exercise
Exercise
Exercise
Ask an assistant
5. Conditionals and Recursion
Integer division and modulus
Boolean Expressions
Logical operators
if statements
The else clause
Chained conditionals
Nested Conditionals
Recursion
Stack diagrams for recursive functions
Infinite recursion
Keyboard input
Debugging
Glossary
Exercises
Ask an assistant
Exercise
Exercise
Exercise
Exercise
Exercise
Exercise
6. Return Values
Some functions have return values
And some have None
Return values and conditionals
Incremental development
Boolean functions
Recursion with return values
Leap of faith
Fibonacci
Checking types
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
Exercise
7. Iteration and Search
Loops and strings
Reading the word list
Updating variables
Looping and counting
The in operator
Search
Doctest
Glossary
Exercises
Ask a Virtual Assistant
Exercise
Exercise
Exercise
Exercise
Exercise
Exercise
Exercise
8. Strings and Regular Expressions
A string is a sequence
String slices
Strings are immutable
String comparison
String methods
Writing files
Find and replace
Regular expressions
String substitution
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
Exercise
9. Lists
A list is a sequence
Lists are mutable
List slices
List operations
List methods
Lists and strings
Looping through a list
Sorting lists
Objects and values
Aliasing
List arguments
Making a word list
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
Exercise
10. Dictionaries
A dictionary is a mapping
Creating dictionaries
The in operator
A collection of counters
Looping and dictionaries
Lists and dictionaries
Accumulating a list
Memos
Debugging
Glossary
Exercises
Ask an assistant
Exercise
Exercise
Exercise
Exercise
Exercise
11. Tuples
Tuples are like lists
But tuples are immutable
Tuple assignment
Tuples as return values
Argument packing
Zip
Comparing and Sorting
Inverting a dictionary
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
Exercise
Exercise
Exercise
12. Text Analysis and Generation
Unique words
Punctuation
Word frequencies
Optional parameters
Dictionary subtraction
Random numbers
Bigrams
Markov analysis
Generating text
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
13. Files and Databases
Filenames and paths
f-strings
YAML
Shelve
Storing data structures
Checking for equivalent files
Walking directories
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
14. Classes and Functions
Programmer-defined types
Attributes
Objects as return values
Objects are mutable
Copying
Pure functions
Prototype and patch
Design-first development
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
15. Classes and Methods
Defining methods
Another method
Static methods
Comparing Time objects
The str method
The init method
Operator overloading
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
16. Classes and Objects
Creating a Point
Creating a Line
Equivalence and identity
Creating a Rectangle
Changing rectangles
Deep copy
Polymorphism
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
Exercise
Exercise
17. Inheritance
Representing cards
Card attributes
Printing cards
Comparing cards
Decks
Printing the deck
Add, remove, shuffle and sort
Parents and children
Specialization
Debugging
Glossary
Exercises
Ask a Virtual Assistant
Exercise
Exercise
Exercise
Exercise
Exercise
Exercise
Exercise
18. Python Extras
Sets
Counters
defaultdict
Conditional expressions
List comprehensions
any and all
Named tuples
Packing keyword arguments
Debugging
Glossary
Exercises
Ask a virtual assistant
Exercise
Exercise
Exercise
Exercise
Exercise
Exercise
19. Final thoughts
Index
π SIMILAR VOLUMES
Master the art of Python programming with 125 actionable best practices to write more efficient, readable, and maintainable code. Python is a versatile and powerful language, but leveraging its full potential requires more than just knowing the syntax. Effective Python: 125 Specific Ways to Write
What will you learn from this book? Ready to learn Java? This book combines puzzles, strong visuals, mysteries, and soul-searching interviews with famous Java objects to engage you in many different ways. It's fast, it's fun, and it's effective. And despite its playful appearance, Head First Java
Want to learn the Python language without slogging your way through how-to manuals? With Head First Python, you'll quickly grasp Python's fundamentals, working with the built-in data structures and functions. Then you'll move on to building your very own webapp, exploring database management, except
Ideal for working programmers new to Java, this best-selling book guides you through the language features and APIs of Java 21. Through fun, compelling, and realistic examples, author Marc Loy introduces you to Java fundamentals, including its class libraries, programming techniques, and idioms, wit
About the Author Mark Lutz is the world leader in Python training, the author of Python's earliest and best-selling texts, and a pioneering figure in the Python community since 1992. He is also the author of O'Reilly's Programming Python, 3rd Edition and Python Pocket Reference, 3rd Edition. Mark