Book description
Learn the fundamentals of clean, effective Python coding and build the practical skills to tackle your own software development or data science projects
Key Features
 Build key Python skills with engaging development tasks and challenging activities
 Implement useful algorithms and write programs to solve realworld problems
 Apply Python in realistic data science projects and create simple machine learning models
Book Description
Have you always wanted to learn Python, but never quite known how to start?
More applications than we realize are being developed using Python because it is easy to learn, read, and write. You can now start learning the language quickly and effectively with the help of this interactive tutorial.
The Python Workshop starts by showing you how to correctly apply Python syntax to write simple programs, and how to use appropriate Python structures to store and retrieve data. You'll see how to handle files, deal with errors, and use classes and methods to write concise, reusable, and efficient code.
As you advance, you'll understand how to use the standard library, debug code to troubleshoot problems, and write unit tests to validate application behavior.
You'll gain insights into using the pandas and NumPy libraries for analyzing data, and the graphical libraries of Matplotlib and Seaborn to create impactful data visualizations. By focusing on entrylevel data science, you'll build your practical Python skills in a way that mirrors realworld development. Finally, you'll discover the key steps in building and using simple machine learning algorithms.
By the end of this Python book, you'll have the knowledge, skills and confidence to creatively tackle your own ambitious projects with Python.
What you will learn
 Write clean and wellcommented code that is easy to maintain
 Automate essential daytoday tasks with Python scripts
 Debug logical errors and handle exceptions in your programs
 Explore data science fundamentals and create engaging visualizations
 Get started with predictive machine learning
 Keep your development process bugfree with automated testing
Who this book is for
This book is designed for anyone who is new to the Python programming language. Whether you're an aspiring software engineer or data scientist, or are just curious about learning how to code with Python, this book is for you. No prior programming experience is required.
Publisher resources
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
 SubClassing Classes from Python Packages
 Exercise 82: SubClassing 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 CommandLine 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
 CrossValidation
 Regularization: Ridge and Lasso

KNearest Neighbors, Decision Trees, and Random Forests
 KNearest Neighbors
 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
 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
video
Python Fundamentals
51+ hours of video instruction. Overview The professional programmer’s Deitel® video guide to Python development with …
book
Learning Python, 5th Edition
Get a comprehensive, indepth introduction to the core Python language with this handson book. Based on …
book
Python Projects for Beginners: A TenWeek Bootcamp Approach to Python Programming
Immerse yourself in learning Python and introductory data analytics with this book’s projectbased approach. Through the …
book
40 Algorithms Every Programmer Should Know
Learn algorithms for solving classic computer science problems with this concise guide covering everything from fundamental …