Mar 10, 2021 - This cheat sheet is about Python. It is one of the most used high-level programming languages. Most coders prefer using Python for developing artificial. In this cheat sheet we will be focusing on only Python 3 because on January 1st, 2020 the community decided to stop supporting Python 2 any further. This event was called Sunsetting Python 2.
Cheat sheets can be really helpful when you’re trying a set of exercises related to a specific topic, or working on a project. Because you can only fit so much information on a single sheet of paper, most cheat sheets are a simple listing of syntax rules. This set of cheat sheets aims to remind you of syntax rules, but also remind you of important concepts as well. You can click here and download all of the original sheets in a single document.
A more recently updated version of these sheets (April 2021) is available through Leanpub. The updated version includes a sheet that focuses on Git basics, a printer-friendly b&w version of each sheet, and each sheet as a separate document. There is an option to download the fully updated set at no cost.
If you’d like to know when more resources become available, you can sign up for email notifications here.
Overview Sheet
- Beginner’s Python Cheat Sheet
- Provides an overview of the basics of Python including variables, lists, dictionaries, functions, classes, and more.
Python Basics
- Beginner’s Python Cheat Sheet - Lists
- Focuses on lists: how to build and modify a list, access elements from a list, and loop through the values in a list. Also covers numerical lists, list comprehensions, tuples, and more.
- Beginner’s Python Cheat Sheet - Dictionaries
- Focuses on dictionaries: how to build and modify a dictionary, access the information in a dictionary, and loop through dictionaries in a variety of ways. Includes sections on nesting lists and dictionaries, using dictionary comprehensions, and more.
- Beginner’s Python Cheat Sheet - If Statements and While Loops
- Focuses on if statements and while loops: how to write conditional tests with strings and numerical data, how to write simple and complex if statements, and how to accept user input. Also covers a variety of approaches to using while loops.
- Beginner’s Python Cheat Sheet - Functions
- Focuses on functions: how to define a function and how to pass information to a function. Covers positional and keyword arguments, return values, passing lists, using modules, and more
- Beginner’s Python Cheat Sheet - Classes
- Focuses on classes: how to define and use a class. Covers attributes and methods, inheritance and importing, and more.
- Beginner’s Python Cheat Sheet - Files and Exceptions
- Focuses on working with files, and using exceptions to handle errors that might arise as your programs run. Covers reading and writing to files, try-except-else blocks, and storing data using the json module.
- Beginner’s Python Cheat Sheet - Testing Your Code
- Focuses on unit tests and test cases. How to test a function, and how to test a class.
Project-Focused Sheets
- Beginner’s Python Cheat Sheet - Pygame
- Focuses on creating games with Pygame. Creating a game window, rect objects, images, responding to keyboard and mouse input, groups, detecting collisions between game elements, and rendering text
- Beginner’s Python Cheat Sheet - Matplotlib
- Focuses on creating visualizations with Matplotlib. Making line graphs and scatter plots, customizing plots, making multiple plots, and working with time-based data.
- Beginner’s Python Cheat Sheet - Plotly
- Focuses on creating visualizations with Plotly. Making line graphs, scatter plots, and bar graphs, styling plots, making multiple plots, and working with geographical datasets.
- Beginner’s Python Cheat Sheet - Django
- Focuses on creating web apps with Django. Installing Django and starting a project, working with models, building a home page, using templates, using data, and making user accounts.
If you find any errors, please feel free to get in touch:
Email: ehmatthes@gmail.com
Twitter: @ehmatthes
A Cheatsheet to Find the Best-Fit Python Library
Over 137,000 libraries exist in Python’s repository. So, how do you choose the right one for your machine learning project? A cheat sheet on proven uses can help.
Nothing beats Python in finding solutions to complex mathematical and computational problems. It is a versatile language that can be easily used across domains and is easier to debug too.
45% of tech organizations use Python for their machine learning and AI projects. – Builtwith.com
Python libraries are a work in progress and their use cases and toolkits are continuously advancing. Therefore, AI engineers need to keep a constant tab on the latest developments, more so if they intend to use Python for their machine learning projects.
Python can be used by beginners and experienced AI Engineers, which makes it a popular choice across levels.
Before we begin with the cheat sheet, please note that Python libraries can be multi-purpose and can be placed in multiple categories. Also, the use of libraries is not constrained to the highlighted tasks.
This cheat sheet aims to help you dig out the best fit.
Top Python Libraries for Deep Learning
We’ve weighed the pros and cons and arrived at these four top picks.
TensorFlow
A plug-and-play library with an extensive resource of commonly-used machine learning models and algorithms, TensorFlow comes with facial recognition capabilities. It is one of the biggest open-source Python libraries and a must-have for beginners.
Level: Good for beginners
Keras
It runs on top of libraries like CNTK, Theano, and TensorFlow, and offers specific support to deep learning applications. Easier prototyping, modularity, and a user-friendly interface make it an excellent choice for beginners.
Level: Excellent choice for beginners
Caffe
Convolutional Architecture for Fast Feature Embedding (Caffe) reiterates versions of an algorithm to get the best solution in time. Mostly used for image classification and segmentation, it is popular in academic research and industrial applications.
Level: Steep learning curve for beginners
PyTorch
With an option to create an n-dimensional array, it gives more control over a dataset. PyTorch functions well with statistical operations and is popular among researchers.
Level: Good for beginners
Top Python Libraries for Computer Vision
If you want to preprocess images and videos for machine learning, check out these three libraries.

OpenCV
One of the oldest libraries for computer vision applications, OpenCV supports PyTorch, TensorFlow, and Caffe. Its features include:
Object identification
Facial recognition
Object extraction
Action classification
Tracking
Reverse image search
Its image modification features can remove red eye, detect scenes, do AR overlays, and correct eye movement.
Level: Steep learning curve for beginners
MATLAB
Generally used for research purposes, this library is a great choice for fast prototyping. One of the main advantages of MATLAB is that it can handle errors before execution.
Level: Steep learning curve for beginners
CUDA
It uses the power of GPU to deliver impressive video, image, and signal functions.
TensorFlow and Keras can also be used for computer vision.
Top Python Libraries for Visualization
Python is an unmatched language for data manipulation and visualization in deep learning. Visualization helps machine learning engineers present their results in an understandable way.
Use these libraries to get the best outputs.
Matplotlib
Best Python Cheat Sheet Github
This visualizer can create plots like histograms, line charts, scatter plots, and bar charts to find patterns in data. Its figures are interactive and the designer has full control over its properties. The final output can be extended to different formats.
Level: Knowledge of MATLAB helps
Seaborn
Based on Matplotlib, Seaborn is an excellent choice to create a high-level interface. If you are looking to create pretty charts, get this one.
Bokeh
A library for modern web browsers, Bokeh can be the right choice if you are looking for high- performance, interactive visualizations in large streaming datasets.
Python 3 Quick Reference Card
Top Libraries for Data Manipulation
These three libraries are excellent for data preprocessing and wrangling.
Pandas
Pandas is an excellent choice for statistical functions and data analysis. It makes preprocessing and data wrangling easy with its easy-to-use structures. It can perform complex functions. Its tools include:
Data indexing
Data manipulation
Reshaping data sets
Merging and joining data set
Filtering data
Time series functionality
Reading and writing data in memory data structures
Level: Previous knowledge of NumPy helps
NumPy
A must-have library for efficiently handling data and numbers, NumPy offers a transformative function for your data. It changes the inbuilt list data structure of Python and creates an n-dimensional array. It can also make your data adaptable. Mostly used for scientific and research applications, NumPy is also used to create generic data.
It is a great library to handle heterogeneous data and gives greater freedom with data. NumPy finds its best use in solving random numbers, linear algebra, and transformations.
Level: Suitable for beginners
Scikit-Learn
If data analysis is what you are looking for, then Scikit-Learn is the best library. It can help you with data classification and structuring. Its uses extend to clustering, regression, model selection dimensionality reduction, and data preprocessing, and it has gradient boosting, random forests, and support vector machines algorithms.
Scikit-Learn is the most popular machine learning library and 40% of projects on GitHub use Scikit-Learn.
Level: Excellent choice for beginners
Top Python Libraries for Web Scraping
These are our top picks for web scraping.
Scrapy
It systematically crawls the web and scrapes data for you, and can be used for mining, monitoring, automating, and testing data.Beautiful Soup
It can extract information from HTML and XML files. Its simplicity and ease of use make it ideal for beginners. It is an excellent option for scraping unstructured information for small projects.
Top Python Libraries for Natural Language Processing (NLP)
NLTK
With its roots in educational purposes, NLTK has produced major breakthroughs. It is used for:
Classification
Stemming
Tagging
Parsing
Semantic reasoning
Tokenization
Level: Steep learning curve
The applications of Python are extensive, and this list must not be taken as the final benchmark. Having a working knowledge of these libraries can help you efficiently solve problems and improve your understanding of machine learning.
So, which is your favorite library? Do you want to add your favorite library here? Write to us.
Follow us for our next update on top Python libraries for 3D machine learning.
Cheat Sheet For Python
Follow Us!
