The
Built by a team of experts to help you unlock your next promotion, reboot your career, or kick off your latest side project.
Enter Early Access
You'll be up and running with Python in no time at all.

$89.00
$89.00The Python Workshop
Buy today and access modules as they're released!
Engineered for Success
Nobody likes going through hundreds of pages of dry theory, or struggling with uninteresting examples that don’t compile. We've got you covered. Any time, any device.

Learn by doing realworld development, supported by detailed stepbystep examples, screencasts and knowledge checks.

Become a verified practitioner, building your credentials by completing exercises, activities and assessment checks.

Manage your learning based on your personal schedule, with content structured to easily let you pause and progress at will.
Learn By Doing
You know you want to learn Python, and the best way to learn Python is to learn by doing.
The Python Workshop focuses on building up your practical skills so that you can work towards building your 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.
On Your Terms
Build up and reinforce key skills in a way that feels rewarding.
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 scripting. It's your choice.
An Ideal Start
Fastpaced and direct, The Python Workshop is the ideal companion for newcomers.
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.
Begin Your Journey
A simple, straightforward and painfree way to learn Python.

$89.00
$89.00The Python Workshop
Enter early access and get started right away!
Everything You Need
Every Workshop includes free access to a whole host of bonus downloadable content. No hidden fees or annoying DRM policies. Just pure, topquality content.

Download a textonly version of the entire Workshop. Perfect for those moments where your WiFi connection is a bit spotty. Available as PDF or EPUB, and always DRMfree.

Save any of our stepbystep screencasts directly from our interactive player. You can rest easy knowing that you'll always have a live example to hand.
Get BuildReady
Every Workshop includes a whole host of features that work together to help you get the job done. You’ll be ready to tackle realworld development in no time.
What's Inside
From A to Z, we've got you covered!

1
Early Access: The Python Workshop
 Installation and Setup
 PreCourse Assessment

2
1. Vital Python: Math, Strings, Conditionals, and Loops
 Overview
 Numbers: Operations, Types, and Variables
 Python as a Calculator
 Exercise 1: StepbyStep
 Exercise 1: Getting to Know the Order of Operations
 Spacing in Python
 Exercise 2: StepbyStep
 Exercise 2: Integer and Float Types
 Complex Number Types
 Errors in Python
 Exercise 3: StepbyStep
 Exercise 3: Assigning Variables
 Changing Types
 Activity 1: StepbyStep
 Activity 1: Assigning Values to Variables
 Variable Names
 Exercise 4: StepbyStep
 Exercise 4: Variable Names
 Exercise 5: StepbyStep
 Exercise 5: Multiple Variables in Python
 Exercise 6: StepbyStep
 Exercise 6: Comments in Python
 Docstrings
 Activity 2: StepbyStep
 Activity 2: Finding a Solution Using Pythagorean Theorem in Python
 Strings: Concatenation, Methods, and input()
 Exercise 7: StepbyStep
 Exercise 7: String Error Syntax
 Escape Sequences with Quotes
 Exercise 8: StepbyStep
 Exercise 8: Displaying Strings
 Exercise 9: StepbyStep
 Exercise 9: String Concatenation
 String Interpolation
 Exercise 10: StepbyStep
 Exercise 10: String Methods
 Exercise 11: StepbyStep
 Exercise 11: Types and Casting
 Exercise 12: StepbyStep
 Exercise 12: The input() Function
 Activity 3: StepbyStep
 Activity 3: Using the input() Function to Rate You Day
 String Indexing and Slicing
 Slicing
 Booleans and Conditionals
 Exercise 13: StepbyStep
 Exercise 13: Boolean Variables
 Logical Operators and Comparison Operators
 Exercise 14: StepbyStep
 Exercise 14: Comparison Operators
 Exercise 15: StepbyStep
 Exercise 15: Comparing Strings
 Conditionals
 Exercise 16: StepbyStep
 Exercise 16: Using the if Syntax
 Exercise 17: StepbyStep
 Exercise 17: Using the ifelse Syntax
 The elif Statement
 Loops
 Activity 4: StepbyStep
 Activity 4: Finding the Least Common Multiple (LCM)
 Programs
 Exercise 18: StepbyStep
 Exercise 18: Calculating Perfect Squares
 Exercise 19: StepbyStep
 Exercise 19: Real Estate Oﬀer
 Exercise 20: StepbyStep
 Exercise 20: Using for Loops
 Activity 5: StepbyStep
 Activity 5: Building Conversational Bots Using Python
 The continue Keyword
 Quiz 1
 Summary

3
2. Python Structures
 Overview
 The Power of Lists
 Exercise 21: StepbyStep
 Exercise 21: Working with Python Lists
 Matrices as Nested Lists
 Exercise 22: StepbyStep
 Exercise 22: Using a Nested List to Store Data from a Matrix
 Activity 6: StepbyStep
 Activity 6: Using a Nested List to Store Employee Data
 Matrix Operations
 Exercise 23: StepbyStep
 Exercise 23: Implementing Matrix Operations Addition and Subtraction
 Matrix Multiplication Operations
 Exercise 24: StepbyStep
 Exercise 24: Implementing Matrix Operations Multiplication
 Exercise 25: StepbyStep
 Exercise 25: Basic List Operations
 Exercise 26: StepbyStep
 Exercise 26: Accessing an Item from Shopping List Data
 Exercise 27: StepbyStep
 Exercise 27: Adding Items to Our Shopping List
 Dictionary Keys and Values, Methods, Tuples, A Survey of Sets and Choosing Types
 Exercise 28: StepbyStep
 Exercise 28: Using a Dictionary to Store a Movie Record
 Activity 7: StepbyStep
 Activity 7: Storing Company Employee Table Data Using a List and a Dictionary
 Exercise 29: StepbyStep
 Exercise 29: Using the zip() Method to Manipulate Dictionaries
 Exercise 30: StepbyStep
 Exercise 30: Accessing a Dictionary Using Dictionary Methods
 Tuples
 Exercise 31: StepbyStep
 Exercise 31: Exploring Tuple Properties in Our Shopping List
 A Survey of Sets
 Exercise 32: StepbyStep
 Exercise 32: Using Sets in Python
 Set Operations
 Exercise 33: StepbyStep
 Exercise 33: Implementing Set Operations
 Choosing Types
 Summary
 Quiz 2

4
3. Executing Python: Programs, Algorithms, and Functions
 Overview
 Python Scripts and Modules
 Exercise 34: StepbyStep
 Exercise 34: Writing and Executing our First Script
 Exercise 35: StepbyStep
 Exercise 35: Writing and Importing our First Module
 Exercise 36: StepbyStep
 Exercise 36: Adding a Docstring to my_module.py
 Exercise 37: StepbyStep
 Exercise 37: Finding the System Date
 Activity 8: StepbyStep
 Activity 8: What's the Time?
 Python Algorithms
 Exercise 38: StepbyStep
 Exercise 38: The Maximum Number
 Exercise 39: StepbyStep
 Exercise 39: Using Bubble Sort in Python
 Exercise 40: StepbyStep
 Exercise 40: Linear Search in Python
 Exercise 41: StepbyStep
 Exercise 41: Binary Search in Python
 Exercise 42: StepbyStep
 Basic, Iterative and Recursive Functions
 Exercise 42: Defining and Calling the Function in Shell
 Exercise 43: StepbyStep
 Exercise 43: Defining and Calling the Function in Python Script
 Exercise 44: StepbyStep
 Exercise 44: Importing and Calling the Function from the Shell
 Exercise 45: StepbyStep
 Exercise 45: Defining the Function with Keyword Arguments
 Exercise 46: StepbyStep
 Exercise 46: Defining the Function with Positional and Keyword Arguments
 Exercise 47: StepbyStep
 Exercise 47: Using **kwargs
 Activity 9: StepbyStep
 Activity 9: Formatting Customer Names
 Exercise 48: StepbyStep
 Exercise 48: A Simple Function with a For Loop
 Exercise 49: StepbyStep
 Exercise 49: Exiting the Function During the For Loop
 Activity 10: StepbyStep
 Activity 10: The Fibonacci Function with an Iteration
 Exercise 50: StepbyStep
 Exercise 50: Recursive Countdown
 Exercise 51: StepbyStep
 Exercise 51: Factorials with Iteration and Recursion
 Activity 11: StepbyStep
 Activity 11: The Fibonacci Function with Recursion
 Dynamic Programming and Helper Functions
 Exercise 52: StepbyStep
 Exercise 52: Summing Integers
 Exercise 53: StepbyStep
 Exercise 53: Timing Your Code
 Activity 12: StepbyStep
 Activity 12: The Fibonacci Function with Dynamic Programming
 Exercise 54: StepbyStep
 Exercise 54: Helper Currency Conversion
 Variable Scope
 Lambda Functions
 Exercise 55: StepbyStep
 Exercise 55: The First Item in a List
 Exercise 56: StepbyStep
 Exercise 56: Mapping with a Logistic Transform
 Exercise 57: StepbyStep
 Exercise 57: Using the Filter Lambda
 Summary
 Quiz 3

5
4. Extending Python, Files, Errors, and Graphs
 Overview
 Reading, Writing Files and Preparing for Debugging (Defensive Code)
 Exercise 58: StepbyStep
 Exercise 58: Reading a Text File Using Python
 Exercise 59: StepbyStep
 Exercise 59: Reading Partial Content from a Text File
 Exercise 60: StepbyStep
 Exercise 60: Creating and Writing Content to Files to Record the Date and Time in a Text File
 Exercise 61: StepbyStep
 Exercise 61: Working with Incorrect Parameters to Find the Average Using Assert with Functions
 Plotting Techniques
 Exercise 62: StepbyStep
 Exercise 62: Drawing a Scatter Plot to Study the Data between Ice Cream Sales versus Temperature
 Exercise 63: StepbyStep
 Exercise 63: Drawing a Line Chart to Find the Growth in Stock Prices
 Exercise 64: Plotting Bar Plots to Grade Students
 Exercise 64: StepbyStep
 Exercise 65: Creating a Pie Chart to Visualize the Number of Votes in a School
 Exercise 65: StepbyStep
 Exercise 66: StepbyStep
 Exercise 66: Generating a Heatmap to Visualize the Grades of Students
 Exercise 67: StepbyStep
 Exercise 67: Generating a Density Plot to Visualize the Score of Students
 Exercise 68: StepbyStep
 Exercise 68: Creating a Contour Plot
 Exercise 69: Generating 3D plots to Plot a Sine Wave
 Exercise 69: StepbyStep
 The Don'ts of Plotting Graphs
 Activity 13: StepbyStep
 Activity 13: Visualizing the Titanic Dataset Using a Pie Chart and Bar Plots
 Quiz 4

6
5. Constructing Python: Classes and Methods
 Overview
 Classes and Objects
 Exercise 70: StepbyStep
 Exercise 70: Exploring Strings
 Exercise 71: StepbyStep
 Exercise 71: Creating a Pet Class
 Exercise 72: StepbyStep
 Exercise 72: Creating a Circle Class
 Exercise 73: The Country Class with Keyword Arguments
 Exercise 73: StepbyStep
 Methods
 Exercise 74: StepbyStep
 Exercise 74: Adding an Instance Method to Our Pet Class
 Exercise 75: Computing the Size of Our Country
 Exercise 75: StepbyStep
 Exercise 76: Adding a __str__ Method to the Country Class
 Exercise 76: StepbyStep
 Exercise 77: Refactoring Instance Methods Using a Static Method
 Exercise 77: StepbyStep
 Exercise 78: Extending Our Pet Class with Class Methods
 Exercise 78: StepbyStep
 Properties
 Exercise 79: StepbyStep
 Exercise 79: The Full Name Property
 Exercise 80: Writing a Setter Method
 Exercise 80: StepbyStep
 Inheritance
 Exercise 81: Inheriting from the Person Class
 Exercise 81: StepbyStep
 Exercise 82: SubClassing the datetime.date Class
 Exercise 82: StepbyStep
 Exercise 83: Overriding Methods Using super()
 Exercise 83: StepbyStep
 Exercise 84: Creating Organized Adults and Babies
 Exercise 84: StepbyStep
 Activity 14: Creating Classes and Inheriting from a Parent Class
 Activity 14: StepbyStep
 Summary
 Quiz 5

7
6. The Standard Library
 Overview
 The Importance of the Standard Library
 Exercise 85: StepbyStep
 Exercise 85: Using the dataclass Module
 Exercise 86: StepbyStep
 Exercise 86: Extending the echo.py Example
 Dates and Times
 Exercise 87: StepbyStep
 Exercise 87: Comparing datetime across Time Zones
 Exercise 88: StepbyStep
 Exercise 88: Calculating the Time Delta between Two datetime Objects
 Exercise 89: StepbyStep
 Exercise 89: Calculating the Unix Epoch Time
 Activity 15: StepbyStep
 Activity 15: Calculating the Time Elapsed to Run a Loop
 Interacting with the OS and Using the Subprocess Module
 Exercise 90: StepbyStep
 Exercise 90: Inspecting the Current Process Information
 Exercise 91: Using the glob Pattern to List Files within a Directory
 Exercise 91: StepbyStep
 Exercise 92: Customizing Child Processes with env vars
 Exercise 92: StepbyStep
 Activity 16: StepbyStep
 Activity 16: Testing Python Code
 Logging
 Exercise 93: Using a logger Object
 Exercise 93: StepbyStep
 Exercise 94: StepbyStep
 Exercise 94: Confguring the Logging Stack
 Collections
 Exercise 95: StepbyStep
 Exercise 95: Counting Words in a Text Document
 Exercise 96: StepbyStep
 Exercise 96: Refactoring Code with defaultdict
 Functools
 Exercise 97: Using lru_cache to Speed Up Our Code
 Exercise 97: StepbyStep
 Exercise 98: StepbyStep
 Exercise 98: Creating a print Function That Writes to stderr
 Activity 17: Using partial on class Methods
 Activity 17: StepbyStep
 Summary
 Quiz 6

8
7. Becoming Pythonic
 Overview
 List, Set and Dictionary Comprehensions
 Exercise 99: StepbyStep
 Exercise 99: Introducing List Comprehensions
 Exercise 100: StepbyStep
 Exercise 100: Using Multiple Input Lists
 Activity 18: Building a Chess Tournament
 Activity 18: StepbyStep
 Exercise 101: Using Set Comprehensions
 Exercise 101: StepbyStep
 Exercise 102: Using Dictionary Comprehensions
 Exercise 102: StepbyStep
 Activity 19: Building a Scorecard Using Dictionary Comprehensions and Multiple Lists
 Activity 19: StepbyStep
 Exercise 103: StepbyStep
 Exercise 103: Adopting a Default Dict
 Iterators, Itertools and Generators
 Exercise 104: StepbyStep
 Exercise 104: The Simplest Iterator
 Exercise 105: A Custom Iterator
 Exercise 105: StepbyStep
 Exercise 106: Controlling the Iteration
 Exercise 106: StepbyStep
 Exercise 107: StepbyStep
 Exercise 107: Using Infnite Sequences and takewhile
 Exercise 108: StepbyStep
 Exercise 108: Turning a Finite Sequence into an Infnite One, and Back Again
 Exercise 109: StepbyStep
 Exercise 109: Generating a Sieve
 Activity 20: Using Random Numbers to Find the Value of Pi
 Activity 20: StepbyStep
 Regular Expressions
 Exercise 110: Matching Text with Regular Expressions
 Exercise 110: StepbyStep
 Exercise 111: StepbyStep
 Exercise 111: Using Regular Expressions to Replace Text
 Activity 21: Regular Expressions
 Activity 21: Regular Expressions
 Summary
 Quiz 7

9
8. Software Development
 Overview
 Debugging
 Exercise 112: StepbyStep
 Exercise 112: Debugging a Salary Calculator
 Activity 22: StepbyStep
 Activity 22: Debugging Sample Python Code for an Application
 Automated Testing
 Exercise 113: StepbyStep
 Exercise 113: Checking Sample Code with Unit Testing
 Creating a PIP Package
 Exercise 114: StepbyStep
 Exercise 114: Creating a Distribution That Includes Multiple Files within a Package
 Creating Documentation the Easy Way
 Exercise 115: Documenting a Divisible Code File
 Exercise 115: StepbyStep
 Source Management
 Exercise 116: StepbyStep
 Exercise 116: Making a Change in CPython Using git
 Summary
 Quiz 8

10
9. Practical Python: Advanced Topics
 Overview
 Developing Collaboratively
 Exercise 117: StepbyStep
 Exercise 117: Writing Python on GitHub as a Team
 Dependency Management
 Exercise 118: StepbyStep
 Exercise 118: Creating and Setting Up a conda Virtual Environment to Install numpy and pandas
 Exercise 119: StepbyStep
 Exercise 119: Sharing Environments between a conda Server and Your Local System
 Deploying Code into Production
 Exercise 120: StepbyStep
 Exercise 120: Dockerizing Your Fizzbuzz Tool
 Multiprocessing
 Exercise 121: StepbyStep
 Exercise 121: Working with execnet to Execute a Simple Python Squaring
 Exercise 122: Using the Multiprocessing Package to Execute a Simple Python Program
 Exercise 122: StepbyStep
 Exercise 123: Using the Threading Package
 Exercise 123: StepbyStep
 Parsing CommandLine Arguments in Scripts
 Exercise 124: StepbyStep
 Exercise 124: Introducing argparse to Accept Input from the User
 Exercise 125: Using Positional Arguments to Accept Source and Destination Inputs_from_a_User
 Exercise 125: StepbyStep
 Performance and Profiling
 Exercise 126: Using PyPy to Find the Time to Get a List of Prime Numbers
 Exercise 126: StepbyStep
 Profiling
 Exercise 127: StepbyStep
 Exercise 127: Adopting Cython to Find the Time Taken to get a List of Prime Numbers
 Activity 23: Generating a List of Random Numbers in a Python Virtual Environment
 Activity 23: StepbyStep
 Summary
 Quiz 9

11
10. Data Analytics with pandas and NumPy
 Overview
 NumPy and Basic Stats
 Exercise 128: StepbyStep
 Exercise 128: Converting Lists to NumPy Arrays
 Exercise 129: StepbyStep
 Exercise 129: Calculating the Mean of the Test Score
 Exercise 130: StepbyStep
 Exercise 130: Finding the Median from a Collection of Income Data
 Exercise 131: Finding the Standard Deviation from Income Data
 Exercise 131: StepbyStep
 Matrices
 Exercise 132: Matrices
 Exercise 132: StepbyStep
 Exercise 133: Creating an Array to Implement NumPy Computations
 Exercise 133: StepbyStep
 The pandas Library
 Exercise 134: StepbyStep
 Exercise 134: Using DataFrames to Manipulate Stored Student testscore Data
 Exercise 135: DataFrame Computations with the Student testscore Data
 Exercise 135: StepbyStep
 Exercise 136: Computing DataFrames within DataFrames
 Exercise 136: StepbyStep
 Exercise 137: Concatenating and Finding the Mean with Null Values for Our testscore Data
 Exercise 137: StepbyStep
 Data
 Exercise 138: Reading and Viewing the Boston Housing Dataset
 Exercise 138: StepbyStep
 Exercise 139: Gaining Data Insights on the Boston Housing Dataset
 Exercise 139: StepbyStep
 Null Values
 Exercise 140: Null Value Operations on the Dataset
 Exercise 140: StepbyStep
 Visual Analysis
 Exercise 141: Creating a Histogram Using the Boston Housing Dataset
 Exercise 141: StepbyStep
 Exercise 142: Creating a Scatter Plot for the Boston Housing Dataset
 Exercise 142: StepbyStep
 Exercise 143: Correlation Values from the Dataset
 Exercise 143: StepbyStep
 Exercise 144: Box Plots
 Exercise 144: StepbyStep
 Activity 24: Data Analysis to Find the Outliers in Pay versus the Salary Report in the UK Statistics Dataset
 Activity 24: StepbyStep
 Summary
 Quiz 10

12
11. Machine Learning
 Overview
 Introduction to Linear Regression
 Exercise 145: StepbyStep
 Exercise 145: Using Linear Regression to Predict the Accuracy of the Median Values of Our Dataset
 CrossValidation
 Exercise 146: StepbyStep
 Exercise 146: Using the cross_val_score Function to Get Accurate Results on the Dataset
 KNearest Neighbors, Decision Trees, and Random Forests
 Exercise 147: StepbyStep
 Exercise 147: Using KNearest Neighbors to Find the Median Value of the Dataset
 Exercise 148: KNearest Neighbors with GridSearchCV to Find the Optimal Number of Neighbors
 Exercise 148: StepbyStep
 Exercise 149: StepbyStep
 Exercise 149: Decision Trees and Random Forests
 Exercise 150: Random Forest Tuned to Improve the Prediction on Our Dataset
 Exercise 150: StepbyStep
 Classification Models
 Exercise 151: Preparing the Pulsar Dataset and Checking for Null Values
 Exercise 151: StepbyStep
 Exercise 152: StepbyStep
 Exercise 152: Using Logistic Regression to Predict Data Accuracy
 Exercise 153: StepbyStep
 Exercise 153: Using GaussianNB, KneighborsClassifer, DecisionTreeClassifer, and RandomForestClassifier to Predict Accuracy in Our Dataset
 Exercise 154: Finding the Pulsar Percentage from the Dataset
 Exercise 154: StepbyStep
 Exercise 155: StepbyStep
 Exercise 155: Confusion Matrix and Classifcation Report for the Pulsar Dataset
 Boosting Methods
 Exercise 156: Using AdaBoost to Predict the Best Optimal Values
 Exercise 156: StepbyStep
 Activity 25: StepbyStep
 Activity 25: Using Machine Learning to Predict Customer Return Return Rate Accuracy
 Summary
 Quiz 11

13
PostCourse Assessment
 PostCourse Assessment
Verify Your Skill
Complete The Python Workshop to unlock your secure credential.
We seal a record of your certification on the public Bitcoin blockchain. This immortalizes your achievement and lets employers authenticate your status with Packt. Our credentials are easy to share, and are ideal for displaying on your LinkedIn profile.
Take A Step Forward
There has never been a better time to start learning Python.

$89.00
$89.00The Python Workshop
Enter early access today!