Getting Started with Python
Understand key data structures and use Python in object-oriented programming
Fabrizio Romano, Benjamin Baka, Dusty Phillips
- 722 pages
- English
- ePUB (adapté aux mobiles)
- Disponible sur iOS et Android
Getting Started with Python
Understand key data structures and use Python in object-oriented programming
Fabrizio Romano, Benjamin Baka, Dusty Phillips
Ă propos de ce livre
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.
Foire aux questions
Informations
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