According to StackOverflow Trends, more than 11 percent of Stack Overflow questions were tagged with "python" in late 2018. All other languages fell well short of this number:
Language | Percent |
---|---|
Python | 11.2% |
Java | 7.7% |
C++ | 2.75% |
R | 2.7% |
Matlab | < 1% |
Scala | < 1% |
SAS | < 1% |
Julia | < 1% |
More recently, the 2021 Stack Overflow Developer Survey shows that Python is used by over 48% of all "developers"
Python is one of the the most popular programming languages in the world. It's commonly used for:
As previously mentioned, Python is also a popular choice in data science. For reference:
Note
Disclaimer: R is terrific and an excellent tool for data science.
Note
We've chosen to use Jupyter over other popular IDEs for this course but that does not mean it is always the best IDE for writing Python.
Note
We've minimized these challenges for this workshop by using Binder. If you are interested in installing and using Jupyter and Python on your own machine, we recommend using Anaconda to do so.
Let's begin by launching Jupyter by opening the Binder repository. This is how we will access Jupyter throughout the course.
You should see a screen like this:
Jupyter can also be launched via Anaconda Navigator:
Note that we want to launch the JupyterLab option for this class.
As you can see, Jupyter displays a file browser when it launches:
There is just one directory for you to worry about:
notebooks - interactive slideshows and code for you to follow along with
The notebook is the core file used to interact with Python from Jupyter. A few details:
.ipynb
(interactive python notebook)A new Jupyter notebook can be opened from the "launcher" page, which opens automatically when you start JupyterLab.
There may be multiple options listed in the Notebooks section, as seen here. These are different Python installations available on your computer. You should choose Python 3 in this case.
This will open a new notebook with a Python 3 kernel:
As previously mentioned, Jupyter notebooks are organized by cells. These cells are at the core of a notebook:
By default, all cells are code cells. This means Python code can be run by simply:
The results of the code will be printed to the output area:
Cells can be converted to text-oriented cells by:
Text can then be typed into these cells (regular text, markdown, HTML, LaTeX):
And it can be rendered by pressing CTRL + RETURN:
New cells can be inserted by selecting a cell by clicking on it and
"a"
to insert cell above or "b"
to insert cell belowx = 5
and run it.Notebooks can be downloaded from Binder in numerous formats by clicking "File" -> "Download"
This is a great way to save your work when using Binder. These notebooks can then be reloaded at any time.
Caution!
New content created in Binder does not persist across sessions. Also, Binder tends to shutdown after a few minutes of inactivity. Save and download your work accordingly!
Are there any questions before moving on?