<jupyter_start><jupyter_text>Crash course in Jupyter and Python- Introduction to Jupyter    - Using Markdown    - Magic functions    - REPL    - Saving and exporting Jupyter notebooks- Python    - Data types    - Operators    - Collections    - Functions and methods    - Control flow    - Loops, comprehension    - Packages and namespace    - Coding style    - Understanding error messages    - Getting help  Class RepositoryCourse material will be posted here. Please make any personal modifications to a **copy** of the notebook to avoid merge conflicts.https://github.com/cliburn/sta-663-2020.git  Introduction to Jupyter- [Official Jupyter docs](https://jupyter.readthedocs.io/en/latest/)- User interface and kernels- Notebook, editor, terminal- Literate programming- Code and markdown cells- Menu and toolbar- Key bindings- Polyglot programming  Using Markdown- What is markdown?- Headers- Formatting text- Syntax-highlighted code- Lists- Hyperlinks and images- LaTeX See `Help | Markdown`  Magic functions- [List of magic functions](https://ipython.readthedocs.io/en/stable/interactive/magics.html)- `%magic`- Shell access- Convenience functions- Quick and dirty text files  REPL- Read, Eval, Print, Loop- Learn by experimentation  Saving and exporting Jupyter notebooks- The File menu item- Save and Checkpoint- Exporting- Close and Halt- Cleaning up with the Running tab  Introduction to Python- [Official Python docs](https://docs.python.org/3/)- [Why Python?](https://insights.stackoverflow.com/trends?tags=python%2Cjavascript%2Cjava%2Cc%2B%2B%2Cr%2Cjulia-lang%2Cscala&utm_source=so-owned&utm_medium=blog&utm_campaign=gen-blog&utm_content=blog-link&utm_term=incredible-growth-python)- General purpose language (web, databases, introductory programming classes)- Language for scientific computation (physics, engineering, statistics, ML, AI)- Human readable- Interpreted- Dynamic typing- Strong typing- Multi-paradigm- Implementations (CPython, PyPy, Jython, IronPython)  Data types- boolean - int, double, complex- strings- None  Operators- mathematical- logical- bitwise- membership- identity- assignment and in-place operators- operator precedence  Arithmetic  Logical  Relational  Bitwise  Membership  Identity  Assignment  Collections- Sequence containers - list, tuple- Mapping containers - set, dict- The [`collections`](https://docs.python.org/2/library/collections.html) module  Lists  Tuples  Sets  Dictionaries  Functions and methods- Anatomy of a function- Docstrings- Class methods  Control flow- if and the ternary operator- Checking conditions - what evaluates as true/false?- if-elif-else- while- break, continue- pass  Loops and comprehensions- for, range, enumerate- lazy and eager evaluation- list, set, dict comprehensions- generator expression  Comprehensions- list- set- dict- generator expressions  Packages and namespace- Modules (file)- Package (hierarchical modules)- Namespace and naming conflicts- Using `import`- [Batteries included](https://docs.python.org/3/library/index.html)<jupyter_code>%%file foo.py

def foo(x):
    return f"And FOO you too, {x}"
import foo
foo.foo("Winnie the Pooh")
from foo import foo
foo("Winnie the Pooh")
import numpy as np
np.random.randint(0, 10, (5,5))<jupyter_output><empty_output><jupyter_text>Coding style- [PEP 8 — the Style Guide for Python Code](https://pep8.org/) - Many code editors can be used with linters to check if your code conforms to PEP 8 style guidelines.- E.g. see [jupyter-autopep8](https://github.com/kenkoooo/jupyter-autopep8)  Understanding error messages- [Built-in exceptions](https://docs.python.org/3/library/exceptions.html)<jupyter_code>try:
    1 / 0
except ZeroDivisionError as e:
    print(e)<jupyter_output><empty_output><jupyter_text>Getting help- `?foo`, `foo?`, `help(foo)`- Use a search engine- Use `StackOverflow`- Ask your TA<jupyter_code>help(help)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09817527627859163, 'fraction_numerical': 0.00796710357234644, 'mean_word_length': 4.715124816446402, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '332820', 'license': 'MIT', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1128, 'n_words': 385, 'path': 'notebooks/S01_Scratch.ipynb', 'repo_name': 'suqianwang/sta-663-2020', 'size': '3891'}