Python Cheatsheet
Free searchable Python 3 cheatsheet: strings, lists, dictionaries, loops, functions, errors, files, classes, modules and virtual environments.
Frequently asked questions
What is the difference between a list and a tuple?
A list can change after you create it: you can add, remove and replace items. A tuple cannot change. Use a tuple for a fixed group of values, such as a pair of coordinates, and a list for a collection that grows or changes.
What is the difference between == and is?
== compares values, so two separate lists with the same items are equal. "is" checks whether two names point to the very same object. Use "is" only to compare with None, True or False.
Why should I use a virtual environment?
A virtual environment keeps each project's packages separate, so installing or upgrading a package for one project cannot break another. Create one with python -m venv .venv and activate it before you install packages.