
Getting Started with Python
Understand key data structures and use Python in object-oriented programming
- 722 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Getting Started with Python
Understand key data structures and use Python in object-oriented programming
About this book
Harness the power of Python objects and data structures to implement algorithms for analyzing your data and efficiently extracting information
Key Features
- Turn your designs into working software by learning the Python syntax
- Write robust code with a solid understanding of Python data structures
- Understand when to use the functional or the OOP approach
Book Description
This Learning Path helps you get comfortable with the world of Python. It starts with a thorough and practical introduction to Python. You'll quickly start writing programs, building websites, and working with data by harnessing Python's renowned data science libraries. With the power of linked lists, binary searches, and sorting algorithms, you'll easily create complex data structures, such as graphs, stacks, and queues. After understanding cooperative inheritance, you'll expertly raise, handle, and manipulate exceptions. You will effortlessly integrate the object-oriented and not-so-object-oriented aspects of Python, and create maintainable applications using higher level design patterns. Once you've covered core topics, you'll understand the joy of unit testing and just how easy it is to create unit tests.
By the end of this Learning Path, you will have built components that are easy to understand, debug, and can be used across different applications.
This Learning Path includes content from the following Packt products:
- Learn Python Programming - Second Edition by Fabrizio Romano
- Python Data Structures and Algorithms by Benjamin Baka
- Python 3 Object-Oriented Programming by Dusty Phillips
What you will learn
- Use data structures and control flow to write code
- Use functions to bundle together a sequence of instructions
- Implement objects in Python by creating classes and defining methods
- Design public interfaces using abstraction, encapsulation and information hiding
- Raise, define, and manipulate exceptions using special error objects
- Create bulletproof and reliable software by writing unit tests
- Learn the common programming patterns and algorithms used in Python
Who this book is for
If you are relatively new to coding and want to write scripts or programs to accomplish tasks using Python, or if you are an object-oriented programmer for other languages and seeking a leg up in the world of Python, then this Learning Path is for you. Though not essential, it will help you to have basic knowledge of programming and OOP.
Tools to learn more effectively

Saving Books

Keyword Search

Annotating Text

Listen to it instead
Information
Built-in Data Types
- Python objects' structures
- Mutability and immutability
- Built-in data types: numbers, strings, sequences, collections, and mapping types
- The collections module
- Enumerations
Everything is an object

Mutable or immutable? That is the question
>>> age = 42
>>> age
42
>>> age = 43 #A
>>> age
43
>>> age = 42
>>> id(age)
4377553168
>>> age = 43
>>> id(age)
4377553200
>>> class Person():
... def __init__(self, age):
... self.age = age
...
>>> fab = Person(age=42)
>>> fab.age
42
>>> id(fab)
4380878496
>>> id(fab.age)
4377553168
>>> fab.age = 25 # I wish!
>>> id(fab) # will be the same
4380878496
>>> id(fab.age) # will be different
4377552624
Numbers
Integers
>>> a = 14
>>> b = 3
>>> a + b # addition
17
>>> a - b # subtraction
11
>>> a * b # multiplication
42
>>> a / b # true division
4.666666666666667
>>> a // b # integer division
4
>>> a % b # modulo operation (reminder of division)
2
>>> a ** b # power operation
2744
>>> 7 / 4 # true division
1.75
>>> 7 // 4 # integer division, truncation returns 1
1
>>> -7 / 4 # true division again, result is opposite of previous
-1.75
>>> -7 // 4 # integer div., result not the opposite of previous
-2
>>> int(1.75)
1
>>> int(-1.75)
-1
Table of contents
- Title Page
- Copyright and Credits
- About Packt
- Contributors
- Preface
- A Gentle Introduction to Python
- Built-in Data Types
- Iterating and Making Decisions
- Functions, the Building Blocks of Code
- Files and Data Persistence
- Principles of Algorithm Design
- Lists and Pointer Structures
- Stacks and Queues
- Trees
- Hashing and Symbol Tables
- Graphs and Other Algorithms
- Searching
- Sorting
- Selection Algorithms
- Object-Oriented Design
- Objects in Python
- When Objects Are Alike
- Expecting the Unexpected
- When to Use Object-Oriented Programming
- Python Object-Oriented Shortcuts
- The Iterator Pattern
- Python Design Patterns I
- Python Design Patterns II
- Testing Object-Oriented Programs
- Other Books You May Enjoy
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app