Skip to content

Commit 3be2da0

Browse files
committed
fix merge conflicts
2 parents 674361a + 6465393 commit 3be2da0

File tree

814 files changed

+143384
-42628
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

814 files changed

+143384
-42628
lines changed

Python/Module1_GettingStartedWithPython/Exercises/Informal_Intro_Python.ipynb

Lines changed: 0 additions & 104 deletions
This file was deleted.

Python/Module1_GettingStartedWithPython/GettingStartedWithPython.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ jupyter:
44
text_representation:
55
extension: .md
66
format_name: markdown
7-
format_version: '1.2'
8-
jupytext_version: 1.3.0rc1
7+
format_version: '1.3'
8+
jupytext_version: 1.13.6
99
kernelspec:
1010
display_name: Python 3
1111
language: python
@@ -15,7 +15,7 @@ jupyter:
1515
<!-- #raw raw_mimetype="text/restructuredtext" -->
1616
.. meta::
1717
:description: Topic: Basic description of the Python programming language, Difficulty: Easy, Category: Background
18-
:keywords: python, install, basics, scripts, interpreter, foundations
18+
:keywords: python, install, basics, scripts, interpreter, foundations, versions
1919
<!-- #endraw -->
2020

2121
<!-- #region -->
@@ -144,6 +144,62 @@ As such, Python is a language that is conducive to rapidly prototyping and testi
144144
We will be relying heavily on Python and a library for doing optimized numerical computations, called NumPy, throughout this course.
145145
<!-- #endregion -->
146146

147+
<!-- #region -->
148+
## Understanding Different Versions of Python
149+
150+
New versions of Python come out periodically, bringing new features and fixes.
151+
You can keep track of what's new in Python by [bookmarking and checking this page every few months](https://docs.python.org/3/whatsnew/index.html).
152+
As we take on coding projects in Python, whether it be for work, school, or a personal hobby, it is important that we remain aware of
153+
the ways in which the language is changing, and that we take care to write code that will remain functional in the future.
154+
155+
All Python version numbers use the `A.B.C` format, in accordance with [semantic versioning](https://semver.org/).
156+
The three numbers denote major releases, minor releases, and patches.
157+
For example, as of writing this, the current release of Python is version `3.9.1`.
158+
159+
The first number denotes major releases to the language.
160+
When a major release comes out, it means that older code will not necessarily work with the new release, and vice versa.
161+
For example, the following code worked in Python 2 but no longer works because the `xrange` function was removed from the language
162+
upon the release of Python 3.
163+
164+
```python
165+
# `xrange` was a frequently-used function in Python 2, but
166+
# was removed from the language in Python 3 in favor of `range`.
167+
# Thus the following code does not work in any version of Python 3.
168+
count = 0
169+
for i in xrange(10):
170+
count = count + 1
171+
```
172+
173+
The most current major release is Python 3; Python 2 is no longer supported by any bug or security fixes and should not be used.
174+
All releases in the near future will be improvements to Python 3, and thus they will come in the form of minor releases and patches.
175+
176+
The second number denotes a minor release.
177+
A minor release will be compatible with code from the preceding release, but it might add new features to the language that are not backwards-compatible.
178+
For example, Python 3.6 introduced [formatted string literals](https://docs.python.org/3/whatsnew/3.6.html#pep-498-formatted-string-literals), which are
179+
commonly referred to as "f-strings".
180+
Thus as of Python 3.6 you could write code like
181+
182+
```python
183+
# Python 3.6 introduced the "f-string" feature, which is not
184+
# backwards compatible with Python 3.5
185+
>>> f"one plus two is {1 + 2}"
186+
'one plus two is 3'
187+
```
188+
189+
but this code would not run in Python 3.5.X.
190+
191+
The third and final number denotes a patch, which generally means bug fixes and performance improvements.
192+
All code within the same minor release will run on all other patches within that minor release
193+
For example, all Python 3.7.8 code is compatible with a Python 3.7.1 interpreter, and vice versa.
194+
Patches are released fairly often, and their changes only occur 'under the hood'.
195+
[Here is a list of changes](https://docs.python.org/3/whatsnew/changelog.html#python-3-9-1-final) were introduced by the patch level increment from Python 3.9.0 to Python 3.9.1;
196+
few of these would affect our day-to-day experience with using Python (which isn't to say that they aren't important!).
197+
198+
In simpler terms, major releases are neither backward nor forward compatible.
199+
Minor releases are forward compatible but not necessarily fully backward compatible, and patches are both forward and backward compatible.
200+
201+
<!-- #endregion -->
202+
147203
## Summary
148204

149205
- Python is a programming language - it provides us with a simple set of grammatical rules that allow us to write human-readable text, which can be translated unambiguously to instruct a computer to perform tasks.

Python/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.md

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ jupyter:
44
text_representation:
55
extension: .md
66
format_name: markdown
7-
format_version: '1.2'
8-
jupytext_version: 1.3.0rc1
7+
format_version: '1.3'
8+
jupytext_version: 1.13.6
99
kernelspec:
1010
display_name: Python 3
1111
language: python
@@ -39,41 +39,51 @@ First and foremost, a good IDE will provide a text editor that will:
3939

4040
An IDE also often provides debugging tools so that you can test your code; it will also typically interface with version-control software, like Git, so that you can keep track of versions of your code as you modify it. We will not discuss these useful, but more advanced features here.
4141

42-
### Recommended IDEs
42+
## Recommended IDEs
4343
There are many excellent IDEs that can be configured to work well with Python. Two IDEs that we endorse are:
44-
45-
[PyCharm](https://www.jetbrains.com/pycharm/download): A powerful IDE dedicated to Python.
44+
45+
### Visual Studio Code
46+
47+
[Visual Studio Code](https://code.visualstudio.com/) (with the [Python extension](https://code.visualstudio.com/docs/languages/python)) is a lightweight, highly customizable IDE that works with many different languages.
48+
49+
Note: if you decide to use VSCode to do Python development, it is highly recommended that you install Microsoft's [PyLance](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance)
50+
extension.
51+
This adds many useful features to the IDE that will make writing Python code a more delightful experience.
4652

4753
**Pros**
4854

49-
- works well out-of-the-box
50-
- long-supported by professionals and thus is very reliable
51-
- highly configurable
52-
- fully-featured, with an excellent debugger, context-dependent "intellisense", type-inference, and more
53-
- the free "community version" is extremely robust and feature-rich.
55+
- Lightweight and elegant.
56+
- Completely free.
57+
- Works with many different languages, so you only need to familiarize yourself with one IDE if you are a polyglot programmer.
58+
- Offers a huge number of extensions that can be downloaded to add functionality to the editor; these are created by a large community of open-source developers.
59+
- [Has native support for Jupyter notebooks](https://code.visualstudio.com/docs/python/jupyter-support), meaning that you get VSCode's intellisense, debugger, and ability to inspect variables, all in a notebook.
60+
- Provides incredibly robust [remote coding](https://code.visualstudio.com/docs/remote/remote-overview) and [collaborative coding](https://visualstudio.microsoft.com/services/live-share/) capabilities.
5461

5562
**Cons**
5663

57-
- can be resource-heavy, especially for a laptop
58-
- may be overwhelming to new users (but has good documentation and tutorials)
59-
- Jupyter notebook support requires the premium version of PyCharm, making it inaccessible to newcomers
60-
61-
[Visual Studio Code](https://code.visualstudio.com/) with the [Python extension](https://code.visualstudio.com/docs/languages/python): A lightweight, highly customizable IDE.
64+
- Configuring VSCode for Python development can have a moderate learning curve for newcomers.
65+
66+
67+
### PyCharm
68+
69+
[PyCharm](https://www.jetbrains.com/pycharm/download) is a powerful and highly-polished IDE dedicated to developing Python code.
6270

6371
**Pros**
6472

65-
- lightweight and elegant
66-
- completely free
67-
- works with many different languages, so you only need to familiarize yourself with one IDE if you are a polyglot programmer
68-
- a huge number of extensions can be downloaded to add functionality to the editor; these are created by a large community of open-source developers.
69-
- [has native support for Jupyter notebooks](https://code.visualstudio.com/docs/python/jupyter-support), meaning that you get VSCode's intellisense, debugger, and ability to inspect variables, all in a notebook.
73+
- Works well out-of-the-box.
74+
- Long-supported by professionals and thus is very reliable.
75+
- Highly configurable.
76+
- Fully-featured, with an excellent debugger, context-dependent "intellisense", type-inference, and more.
77+
- The free "community version" is extremely robust and feature-rich.
78+
- Generally provides an extremely high-quality and responsive experience for doing Python development.
7079

7180
**Cons**
7281

73-
- configuring VSCode for python development can have a moderate learning curve for newcomers
74-
- many features, like context-aware intellisense and type-inference, are simply more polished and powerful in PyCharm
75-
82+
- Can be resource-heavy, especially for a laptop.
83+
- May be overwhelming to new users (but has good documentation and tutorials).
84+
- Jupyter notebook support requires the premium version of PyCharm, making it inaccessible to newcomers.
7685

86+
7787
<div class="alert alert-info">
7888

7989
**Takeaway**:

Python/Module1_GettingStartedWithPython/Informal_Intro_Python.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ jupyter:
44
text_representation:
55
extension: .md
66
format_name: markdown
7-
format_version: '1.2'
8-
jupytext_version: 1.3.0rc1
7+
format_version: '1.3'
8+
jupytext_version: 1.13.6
99
kernelspec:
1010
display_name: Python 3
1111
language: python
@@ -19,6 +19,7 @@ jupyter:
1919
<!-- #endraw -->
2020

2121
# An Informal Introduction to Python
22+
2223
Now that you have the Anaconda distribution of Python installed on your machine, let's write some simple Python code! We are going to forego writing a full Python script for now, and instead make use of a convenient tool for doing quick code scratchwork. The IPython console was installed as a part of Anaconda; it will allow us to build incrementally off of snippets of code, instead of having to execute an entire script all at once.
2324

2425
Let's open an IPython console. Open your terminal if you are a Mac/Linux user, or start `cmd.exe` if you are a Windows user. Now type `ipython` into the console and hit `<Enter>`. You should see the following display on your screen:

Python/Module1_GettingStartedWithPython/Installing_Python.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ jupyter:
44
text_representation:
55
extension: .md
66
format_name: markdown
7-
format_version: '1.2'
8-
jupytext_version: 1.3.0rc1
7+
format_version: '1.3'
8+
jupytext_version: 1.13.6
99
kernelspec:
1010
display_name: Python 3
1111
language: python

Python/Module1_GettingStartedWithPython/Jupyter_Notebooks.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ jupyter:
44
text_representation:
55
extension: .md
66
format_name: markdown
7-
format_version: '1.2'
8-
jupytext_version: 1.3.0rc1
7+
format_version: '1.3'
8+
jupytext_version: 1.13.6
99
kernelspec:
1010
display_name: Python 3
1111
language: python
@@ -19,19 +19,25 @@ jupyter:
1919
<!-- #endraw -->
2020

2121
# Jupyter Notebooks
22-
In recent years, the Jupyter Notebook has become a massively popular tool for doing research-oriented work in Python and other languages alike. Its emergence marked a paradigm shift in the way data science is conducted.
2322

24-
A Jupyter notebook is similar to the IPython console, but, instead of only being able to work with a single line of code at a time, you can easily edit and re-execute *any* code that had been written in a notebook. Furthermore, you can save a notebook, and thus return to it later. Additionally, a notebook provides many terrific features. For instance, you can embed visualizations of data within a notebook, and write blocks of nicely-formatted text (using the [Markdown syntax](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)), for presenting and explaining the contents of the notebook.
23+
In recent years, the Jupyter Notebook has become a massively popular tool for doing research-oriented work in Python and other languages alike.
24+
Its emergence marked a paradigm shift in the way data science is conducted.
25+
26+
A Jupyter notebook is similar to the IPython console, but, instead of only being able to work with a single line of code at a time, you can easily edit and re-execute *any* code that had been written in a notebook. Furthermore, you can save a notebook, and thus return to it later.
27+
Additionally, a notebook provides many terrific features. For instance, you can embed visualizations of data within a notebook, and write blocks of nicely-formatted text (using the [Markdown syntax](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)), for presenting and explaining the contents of the notebook.
2528

2629
In this way, the Jupyter Notebook stands out as an excellent tool for many practical applications. You could work on a notebook while you are working through sections of this website, for instance, testing out snippets of code, and answering reading-comprehension questions as you proceed through the text, and using markdown-headers to visually separate different portions of the notebook. When I do research, I am always creating Jupyter notebooks in which I write code that analyzes data, I plot various results, presented in different ways, and I write detailed markdown-text blocks to document my work. The end result is something that I can share with my labmates, and easily revisit months later without having to struggle to recall what I had done.
2730

2831
## Jupyter Lab
29-
[Jupyter lab](https://jupyterlab.readthedocs.io/) is a new web interface from Project Jupyter that provides a rich web-based interface for managing and running Jupyter notebooks, console terminals, and text editors, all within your browser. Among its useful features and polished user interface - compared to that a Jupyter notebook server - Jupyter lab provides moveable panes for viewing data, images, and code output apart from the rest of the notebook. This is facilitates effective data science work flows.
32+
[Jupyter lab](https://jupyterlab.readthedocs.io/) is a new web interface from Project Jupyter that provides a rich web-based interface for managing and running Jupyter notebooks, console terminals, and text editors, all within your browser.
33+
Among its useful features and polished user interface, Jupyter lab provides moveable panes for viewing data, images, and code output apart from the rest of the notebook.
34+
This is facilitates effective data science work flows.
3035

3136
It is recommended that you peruse the [Jupyter lab documentation](https://jupyterlab.readthedocs.io/en/stable/getting_started/overview.html) to get a feel for all of its added capabilities.
3237

3338

34-
The following instructions are laid out for running a Jupyter notebook server. That being said, the process for running a Jupyter lab server and working with notebooks therein is nearly identical. Both Jupyter notebook and Jupyter lab should already be [installed via Anaconda](https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Installing_Python.html).
39+
The following instructions are laid out for running a Jupyter notebook server. That being said, the process for running a Jupyter lab server and working with notebooks therein is nearly identical.
40+
Both Jupyter notebook and Jupyter lab should already be [installed via Anaconda](https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Installing_Python.html).
3541

3642

3743
## Running a Notebook Server & Creating a Notebook
@@ -100,7 +106,7 @@ import numpy as np
100106
import matplotlib.pyplot as plt
101107

102108
# this tells Jupyter to embed matplotlib plots in the notebook
103-
%matplotlib notebook
109+
%matplotlib inline
104110
```
105111

106112
```python
@@ -186,4 +192,4 @@ The Jupyter Notebook does not work exclusively with Python. A "kernel" can be de
186192
The ever-growing list of available kernels for use with Jupyter can be found [here](https://github.com/jupyter/jupyter/wiki/Jupyter-kernels). It should be noted that these efforts are not all equally mature. For instance, whereas the Python and Julia kernels are robust, the Haskell kernel cannot run natively on Windows machines, and the C++ kernel is still in early development, as of writing this.
187193

188194
### Jupyter Notebook Support in Visual Studio Code
189-
Native Jupyter notebook support was [recently added to Visual Studio Code](https://devblogs.microsoft.com/python/announcing-support-for-native-editing-of-jupyter-notebooks-in-vs-code/). This means that you can now edit Jupyter notebooks within the [Visual Studio Code IDE](https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.html), and that you will benefit from added features like code-completion, debugging, and variable inspection.
195+
[Visual Studio Code provides native support for Jupyter notebooks](https://code.visualstudio.com/docs/datascience/jupyter-notebooks). This means that you can now edit Jupyter notebooks within the [Visual Studio Code IDE](https://www.pythonlikeyoumeanit.com/Module1_GettingStartedWithPython/Getting_Started_With_IDEs_and_Notebooks.html), and that you will benefit from added features like code-completion, debugging, and variable inspection.

0 commit comments

Comments
 (0)