Book description
Cut through the noise and get real results with a step-by-step approach to learning Python 3.X programming
Key Features
- Ideal for the Python beginner who is getting started for the first time
- A step-by-step Python tutorial with exercises and activities that help build key skills
- Structured to let you progress at your own pace, on your own terms
- Use your physical copy to redeem free access to the online interactive edition
Book Description
You already know you want to learn Python, and a smarter way to learn Python 3 is to learn by doing. The Python Workshop focuses on building up your practical skills so that you can work towards building up your machine learning skills as a data scientist, write scripts that help automate your life and save you time, or even create your own games and desktop applications. You'll learn from real examples that lead to real results.
Throughout The Python Workshop, you'll take an engaging step-by-step approach to understanding Python. You won't have to sit through any unnecessary theory. If you're short on time you can jump into a single exercise each day or spend an entire weekend learning about Python scripting. It's your choice. Learning on your terms, you'll build up and reinforce key skills in a way that feels rewarding.
Every physical copy of The Python Workshop unlocks access to the interactive edition. With videos detailing all exercises and activities, you'll always have a guided solution. You can also benchmark yourself against assessments, track progress, and receive free content updates. You'll even earn a secure credential that you can share and verify online upon completion. It's a premium learning experience that's included with your printed copy. To redeem, follow the instructions located at the start of your Python book.
Fast-paced and direct, The Python Workshop is the ideal companion for Python beginners. You'll build and iterate on your code like a software developer, learning along the way. This process means that you'll find that your new skills stick, embedded as best practice. A solid foundation for the years ahead.
What you will learn
- Learn how to write clean and concise code with Python 3
- Understand classes and object-oriented programming
- Tackle entry-level data science and create engaging visualizations
- Use Python to create responsive, modern web applications
- Automate essential day-to-day tasks with Python scripts
- Get started with predictive Python machine learning
Who this book is for
This book is designed for professionals, students, and hobbyists who want to learn Python and apply it to solve challenging real-world problems. Although this is a beginner's book, it will help if you already know standard programming topics, such as variables, if-else statements, and functions. Experience with another object-oriented program is beneficial, but not mandatory.
Table of contents
- Preface
-
1. Vital Python – Math, Strings, Conditionals, and Loops
- Introduction
- Vital Python
- Numbers: Operations, Types, and Variables
-
Python as a Calculator
- Standard Math Operations
- Basic Math Operations
- Order of Operations
- Exercise 1: Getting to Know the Order of Operations
- Spacing in Python
- Number Types: Integers and Floats
- Exercise 2: Integer and Float Types
- Complex Number Types
- Errors in Python
- Variables
- Variable Assignment
- Exercise 3: Assigning Variables
- Changing Types
- Reassigning Variables in Terms of Themselves
- Activity 1: Assigning Values to Variables
- Variable Names
- Exercise 4: Variable Names
- Multiple Variables
- Exercise 5: Multiple Variables in Python
- Comments
- Exercise 6: Comments in Python
- Docstrings
- Activity 2: Finding a Solution Using the Pythagorean Theorem in Python
- Strings: Concatenation, Methods, and input()
- String Interpolation
- String Indexing and Slicing
- Slicing
- Booleans and Conditionals
- Loops
- Summary
- 2. Python Structures
-
3. Executing Python – Programs, Algorithms, and Functions
- Introduction
- Python Scripts and Modules
- Python Algorithms
-
Basic Functions
- Exercise 42: Defining and Calling the Function in Shell
- Exercise 43: Defining and Calling the Function in Python Script
- Exercise 44: Importing and Calling the Function from the Shell
- Positional Arguments
- Keyword Arguments
- Exercise 45: Defining the Function with Keyword Arguments
- Exercise 46: Defining the Function with Positional and Keyword Arguments
- Exercise 47: Using **kwargs
- Activity 9: Formatting Customer Names
- Iterative Functions
- Recursive Functions
- Dynamic Programming
- Helper Functions
- Variable Scope
- Lambda Functions
- Summary
-
4. Extending Python, Files, Errors, and Graphs
- Introduction
- Reading Files
- Writing Files
- Preparing for Debugging (Defensive Code)
-
Plotting Techniques
- Exercise 62: Drawing a Scatter Plot to Study the Data between Ice Cream Sales versus Temperature
- Exercise 63: Drawing a Line Chart to Find the Growth in Stock Prices
- Exercise 64: Plotting Bar Plots to Grade Students
- Exercise 65: Creating a Pie Chart to Visualize the Number of Votes in a School
- Exercise 66: Generating a Heatmap to Visualize the Grades of Students
- Exercise 67: Generating a Density Plot to Visualize the Score of Students
- Exercise 68: Creating a Contour Plot
- Extending Graphs
- Exercise 69: Generating 3D plots to Plot a Sine Wave
- The Don'ts of Plotting Graphs
- Summary
-
5. Constructing Python – Classes and Methods
- Introduction
- Classes and Objects
- Defining Classes
- The __init__ method
-
Methods
- Instance Methods
- Exercise 74: Adding an Instance Method to Our Pet Class
- Adding Arguments to Instance Methods
- Exercise 75: Computing the Size of Our Country
- The __str__ method
- Exercise 76: Adding an __str__ Method to the Country Class
- Static Methods
- Exercise 77: Refactoring Instance Methods Using a Static Method
- Class Methods
- Exercise 78: Extending Our Pet Class with Class Methods
- Properties
-
Inheritance
- The DRY Principle Revisited
- Single Inheritance
- Exercise 81: Inheriting from the Person Class
- Sub-Classing Classes from Python Packages
- Exercise 82: Sub-Classing the datetime.date Class
- Overriding Methods
- Calling the Parent Method with super()
- Exercise 83: Overriding Methods Using super()
- Multiple Inheritance
- Exercise 84: Creating a Consultation Appointment System
- Method Resolution Order
- Activity 14: Creating Classes and Inheriting from a Parent Class
- Summary
- 6. The Standard Library
- 7. Becoming Pythonic
- 8. Software Development
-
9. Practical Python – Advanced Topics
- Introduction
- Developing Collaboratively
- Dependency Management
- Deploying Code into Production
-
Multiprocessing
- Multiprocessing with execnet
- Exercise 121: Working with execnet to Execute a Simple Python Squaring Program
- Multiprocessing with the Multiprocessing Package
- Exercise 122: Using the Multiprocessing Package to Execute a Simple Python Program
- Multiprocessing with the Threading Package
- Exercise 123: Using the Threading Package
- Parsing Command-Line Arguments in Scripts
- Performance and Profiling
- Profiling
- Summary
-
10. Data Analytics with pandas and NumPy
- Introduction
- NumPy and Basic Stats
- Matrices
-
The pandas Library
- Exercise 134: Using DataFrames to Manipulate Stored Student testscore Data
- Exercise 135: DataFrame Computations with the Student testscore Data
- Exercise 136: Computing DataFrames within DataFrames
- New Rows and NaN
- Exercise 137: Concatenating and Finding the Mean with Null Values for Our testscore Data
- Cast Column Types
- Data
- Null Values
-
Visual Analysis
- The matplotlib Library
- Histograms
- Exercise 141: Creating a Histogram Using the Boston Housing Dataset
- Histogram Functions
- Scatter Plots
- Exercise 142: Creating a Scatter Plot for the Boston Housing Dataset
- Correlation
- Exercise 143: Correlation Values from the Dataset
- Regression
- Plotting a Regression Line
- StatsModel Regression Output
- Additional Models
- Exercise 144: Box Plots
- Violin Plots
- Activity 24: Data Analysis to Find the Outliers in Pay versus the Salary Report in the UK Statistics Dataset
- Summary
-
11. Machine Learning
- Introduction
- Introduction to Linear Regression
- Cross-Validation
- Regularization: Ridge and Lasso
-
K-Nearest Neighbors, Decision Trees, and Random Forests
- K-Nearest Neighbors
- Exercise 147: Using K-Nearest Neighbors to Find the Median Value of the Dataset
- Exercise 148: K-Nearest Neighbors with GridSearchCV to Find the Optimal Number of Neighbors
- Decision Trees and Random Forests
- Exercise 149: Decision Trees and Random Forests
- Random Forest Hyperparameters
- Exercise 150: Random Forest Tuned to Improve the Prediction on Our Dataset
-
Classification Models
- Exercise 151: Preparing the Pulsar Dataset and Checking for Null Values
- Logistic Regression
- Exercise 152: Using Logistic Regression to Predict Data Accuracy
- Other Classifiers
- Naive Bayes
- Exercise 153: Using GaussianNB, KneighborsClassifier, DecisionTreeClassifier, and RandomForestClassifier to Predict Accuracy in Our Dataset
- Confusion Matrix
- Exercise 154: Finding the Pulsar Percentage from the Dataset
- Exercise 155: Confusion Matrix and Classification Report for the Pulsar Dataset
- Boosting Methods
- Summary
-
Appendix
- 1. Vital Python – Math, Strings, Conditionals, and Loops
- 2. Python Structures
- 3. Executing Python – Programs, Algorithms, Functions
- 4. Extending Python, Files, Errors, and Graphs
- 5. Constructing Python – Classes and Methods
- 6. The Standard Library
- 7. Becoming Pythonic
- 8. Software Development
- 9. Practical Python – Advanced Topics
- 10. Data Analytics with pandas and NumPy
- 11. Machine Learning
Product information
- Title: The Python Workshop
- Author(s):
- Release date: November 2019
- Publisher(s): Packt Publishing
- ISBN: 9781839218859
You might also like
book
The Big Book of Small Python Projects
If you’ve mastered basic Python syntax and you’re ready to start writing programs, you’ll find The …
book
Beyond the Basic Stuff with Python
You’ve completed a basic Python programming tutorial or finished Al Sweigart’s best selling Automate the Boring …
book
Learn Python Visually
This beginners book introduces non-programmers to the fundamentals of computer coding within a visual, arts-focused context. …
book
Impractical Python Projects
Impractical Python Projects picks up where the complete beginner books leave off, expanding on existing concepts …