<jupyter_start><jupyter_text>Congratulations You've Opened Your First Jupyter Notebook!This notebook briefly introduces the main components of the Jupyter Notebook environment. Table of Contents1&nbsp;&nbsp;Congratulations You've Opened Your First Jupyter Notebook!2&nbsp;&nbsp;Learning Objectives3&nbsp;&nbsp;What Is A Jupyter Notebook?3.1&nbsp;&nbsp;Notebook User Interface3.2&nbsp;&nbsp;What Is A Notebook Cell?3.2.1&nbsp;&nbsp;Code Cells3.2.2&nbsp;&nbsp;Markdown Cells3.2.3&nbsp;&nbsp;Raw Cells4&nbsp;&nbsp;A taste of Python to come...4.1&nbsp;&nbsp;Built-in Types4.1.1&nbsp;&nbsp;Integers4.1.2&nbsp;&nbsp;Floats4.1.3&nbsp;&nbsp;Strings4.1.4&nbsp;&nbsp;Tuples4.1.5&nbsp;&nbsp;Lists4.1.6&nbsp;&nbsp;Sets4.1.7&nbsp;&nbsp;Dicts4.2&nbsp;&nbsp;Whitespace matters!4.2.1&nbsp;&nbsp;The if-elif-else statement...4.2.2&nbsp;&nbsp;The for loop...4.2.3&nbsp;&nbsp;Functions...4.3&nbsp;&nbsp;Pointers: Everything is an object!!!4.3.0.1&nbsp;&nbsp;Be careful!4.4&nbsp;&nbsp;Nothing is something!4.5&nbsp;&nbsp;Going Further  Learning Objectives- Get familiar with Jupyter Notebook Interface- Get a taste of the Python to come... ----------------  What Is A Jupyter Notebook? - **Interactive**, browser-based computing environment- **Exploratory** data science, analysis, visualization- **Reproducible** document format:    - Code    - Narrative text (markdown)    - Equations (LaTeX)    - Images, Visualizations- Supports over over 100 programming languages (called “kernels” in the Jupyter ecosystem) including Python, Fortran, R, Julia, Matlab, NCL, C++, Processing, Scala, and many more. - A Jupyter notebook is internally a JSON file and is saved with the **`.ipynb`** extension.   Notebook User Interface  **Menu bar**: The menu bar presents different options that may be used to manipulate the way the notebook functions.**Toolbar**: The tool bar gives a quick way of performing the most-used operations within the notebook, by clicking on an icon.**Code cell**: the default type of cell; read on for an explanation of cells.**Kernel**: A computational engine that will execute contained in a Jupyter Notebook  What Is A Notebook Cell?The notebook consists of a sequence of cells. A cell is a multiline text input field, and its contents can be executed by using `Shift-Enter`, or by clicking either the “▶” button in the toolbar, or Cell, Run in the menu bar. The execution behavior of a cell is determined by the cell’s type. There are three types of cells: **code cells**, **markdown cells**, and **raw cells**.   Code CellsA code cell allows you to edit and write new code, with full syntax highlighting and tab completion. The programming language you use depends on the kernel, and the default kernel (IPython) runs Python code.<jupyter_code>print("hi, stdout")
import time
import sys
for i in range(8):
    print(i)
    time.sleep(0.5)<jupyter_output><empty_output><jupyter_text>Markdown CellsText can be added to Jupyter Notebooks using Markdown cells. You can change the cell type to Markdown by using the Cell menu, the toolbar, or the key shortcut m. Markdown is a popular markup language that is a superset of HTML. Its specification can be found here: https://daringfireball.net/projects/markdown/ **LaTex Equations**You can include mathematical expressions both inline and displayed:- The Cauchy-Schwarz Inequality$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) $$- A Cross Product Formula $$\mathbf{V}_1 \times \mathbf{V}_2 =  \begin{vmatrix}\mathbf{i} & \mathbf{j} & \mathbf{k} \\\frac{\partial X}{\partial u} &  \frac{\partial Y}{\partial u} & 0 \\\frac{\partial X}{\partial v} &  \frac{\partial Y}{\partial v} & 0\end{vmatrix}$$- The probability of getting \(k\) heads when flipping \(n\) coins is $P(E)   = {n \choose k} p^k (1-p)^{ n-k} $- An Identity of Ramanujan$$\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} =1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}{1+\frac{e^{-8\pi}} {1+\ldots} } } } $$- Maxwell’s Equations$$\begin{aligned}\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\   \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\\nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned}$$  Raw CellsRaw cells provide a place in which you can write output directly. Raw cells are not evaluated by the notebook. How freeing!<jupyter_code># This is a raw cell. Execute it and see what happens.

a = 2 + 2
print(a)<jupyter_output><empty_output><jupyter_text>----------------  A taste of Python to come...Now, let's get a brief look at Python itself, which is run in the Notebook kernel.  Built-in TypesPython has a number of built-in types that it knows how to deal with.  Integers<jupyter_code>i = 3
type(i)<jupyter_output><empty_output><jupyter_text>Floats<jupyter_code>x = 3.73244e-8
type(x)<jupyter_output><empty_output><jupyter_text>Strings<jupyter_code>s1 = 'This is a single-quote string'
s2 = "This is a double-quote string"
type(s1), type(s2)<jupyter_output><empty_output><jupyter_text>Tuples- Order is preserved- Can include duplicates- Cannot be changed after construction- Can be used as a _key_ for `dict`s<jupyter_code>t = (1,2,3)
type(t)
t[1]
t[1] = 4<jupyter_output><empty_output><jupyter_text>Lists- Order is preserved- Can include duplicates- Can be changed after construction<jupyter_code>l = [1,2,3,4]
type(l)
l[1]
l[1] = 3
l<jupyter_output><empty_output><jupyter_text>Sets- Order is not preserved- Contains only unique elements- Can be changed after construction<jupyter_code>s = {1,3,5,8,8,4,5}
type(s)
s
s.add(7)
s
s.remove(3)
s<jupyter_output><empty_output><jupyter_text>Dicts- Order is not preserved- Keys are unique (like a set), but values are not unique- Can be changed after construction<jupyter_code>d = {'a': 1, 'b': 2, 'c': 2}
type(d)
d['a'] = 3
d<jupyter_output><empty_output><jupyter_text>Whitespace matters!Instead of block delimiters, such as `{` and `}` or `FOR` and `ENDFOR`, for blocks of code, Python uses _indentation_ to delineate blocks.  The `if-elif-else` statement...<jupyter_code>if 1 == 2:
    print('What?')

elif 3 == 3:
    print('Yeah.  That looks correct.')

else:
    print("Something's not right!")<jupyter_output><empty_output><jupyter_text>The `for` loop...<jupyter_code>for i in [1,3,6,7]:
    print(i)<jupyter_output><empty_output><jupyter_text>Functions...<jupyter_code>def my_function(x, y, z=3):
    print(x, y, z)
my_function(1, 2)
my_function(1, 2, z=8)<jupyter_output><empty_output><jupyter_text>Pointers: Everything is an object!!!In Python, every variable or function or ...anything... is an `object`.  That is, Python doesn't treat anything as special, so you can pass around functions like you would variables, and you can have variables that can be "function-like".  And unlike a lot of other languages that "pass by value", it is important to recognize that Python symbols (e.g., `x` or `my_function`) are pointers to their values.  ...And you have to be careful when dealing with pointers!<jupyter_code>x = [1, 2, 3]
y = x
y[1] = 3
y
x<jupyter_output><empty_output><jupyter_text>Be careful!<jupyter_code>y == x
y is x
z = [1, 3, 3]
y == z
z is y
id(z)
id(y)
id(x)<jupyter_output><empty_output><jupyter_text>Nothing is something!In some languages, there is a concept of `NULL`.  Python has this concept, too, and it is called `None`.  This is a special symbol that can be used to represent whether a variable is unset, or if it actually represents the "nothing" concept, or similar<jupyter_code>x = None
y = None
x is None
x is y<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13951080626375048, 'fraction_numerical': 0.02057719684224149, 'mean_word_length': 4.908256880733945, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 61, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '170460', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 2675, 'n_tokens_neox': 2551, 'n_words': 878, 'path': 'notebooks/welcome.ipynb', 'repo_name': 'zbruick/ncar-python-tutorial', 'size': '7727'}