Python Flash Cards Booklet - Eric Matthes
Python Flash Cards Booklet - Eric Matthes
Fl a sh Cards
Sy nta x Cards
In order to write code that works, you need to learn the
syntax of a language. These cards show syntax examples
in different forms depending on how the information is best
conveyed: as code from a Python terminal session, snippets
from a full program, or tables.
Py thon on W indows
Download the installer for your system from https://python
.org/downloads/. Run the installer, and make sure to check
the Add Python 3.x to your PATH box. This will ensure your
installation of Python is ready to use.
To start using Python, open a terminal (enter terminal
into the search box on your taskbar) and then enter python
at the terminal prompt. You should see a Python prompt
appear that looks like this: >>>. Enter the text in bold from
the following example, and you should see the output
appear below it:
>>> print("Hello, Python world!")
Hello, Python world!
Py thon on m acOS
You can use the package manager Homebrew to install the
latest version of Python on macOS.
First, install Homebrew: visit the project’s home page at
https://brew.sh/ and follow the directions you see there.
Homebrew might inform you of additional requirements,
which you should also install.
With Homebrew installed, install the latest version of
Python by opening the terminal and entering this command:
$ brew install python
Py thon on Linu x
Python comes installed on most Linux systems, but you’ll
probably want to install a more recent version. On APT-
based systems such as Ubuntu, you can use the deadsnakes
package to do this by entering the following commands into
the terminal:
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.7
To start a Python terminal session and test it, enter the
following:
$ python3.7
>>> print("Hello, Python world!")
Hello, Python world!
Py thon E x amples
When the examples on the cards are based in the terminal,
they will appear like this, where the code you enter comes
after the >>> prompt:
>>> print("Hello, Python world!")
Hello, Python world!