Agenda

Code Words Spells Python Jupyter Notebook

  • Download this zip file, uncompress it and put it in your ~/ folder or in ~/digital-love-languages
  • Open the application, Anaconda and press the button to launch “Jupyter Notebook”

🦋 4 things about Jupyter Notebooks that are cool

Traditionally (and still today) python is written in text editors (like Atom) in files that end in .py and are run in the terminal like so: python3 name_of_file.py

Python files in Jupyter Notebook end with the file extension .ipynb not .py .ipynb stands for iPythonNotebook

There are 4 reasons we will be writing Python together in Jupyter Notebooks instead of the more traditional terminal way described above.

  1. Jupyter Notebook allows you to comment and annotate your code with rich text formatting using markdown. We can even include links and pictures in our code programs. In this way, it’s more like a notebook and we can begin to see how it got at least part of it’s name.
  2. Jupyter Notebook puts blocks or segments of code into cells which allows us to run very small parts of our code at a time whereas traditionally, a .py file run in terminal would run everything at once unless you commented the parts out that you didn’t want to run.
  3. ♡ My favorite thing is that Jupyter Notebook harnesses the graphical power of the browser to display your files and render your code all nicely on a page. It’s a pretty cool use of the browser to manipulate and display your local files, they are not on the public internet yet they are viewed in the browser!
  4. Lastly, Jupyter Notebook makes it an even playing field for students in an educational setting by ensuring everyone has the same python environment setup. Saves a lot of class time to not debug each participants individual Python environment.

🐍 [Insert Python environment joke here]

Overview of Jupyter Notebook and common keyboard shortcuts

  • The most common error when using jupyter notebooks is caused by forgetting to run the cells above where you are in the code
  • Ctrl + Enter runs selected cells
  • Alt + Enter runs the current cell, insert below
  • Ctrl + S saves
  • To convert a cell to markdown press “Cell” at the top > “Cell type” > “Markdown”
  • https://towardsdatascience.com/jypyter-notebook-shortcuts-bf0101a98330

🦋 The 3 levels of language malleability in code in order of least to most malleable

  1. keywords and built in functions of a language
  2. Conventions of a language like calling an indexing variable “i” as in index. These are totally malleable but conventions in programming like social norms are strong! They can feel unchangeable even though they’re changeable.
  3. Your own variable and function names! these can be whatever you want them to be! Sometimes people write them so their code will make more sense to people in the future, sometime people write them to be most understandable just to you, and sometimes they are poetic or silly!

The 33 built in Python keywords (these are special python words you can’t really change) – They are the core of the language

The 69 built in Python functions (these are special python words you can’t really change) – They are also at the core of the language

“A function is a structuring element in programming languages to group a set of statements so they can be utilized more than once in a program.” (https://www.python-course.eu/python3_functions.php)

“Efficiency is often a concern when writing code, you rarely want to write the same thing many times, so we create functions that essentially perform the role of the copy and paste buttons. As a matter of fact, copy and paste ARE functions of the programs you use.” – source

Homework for next week ☼☽

Passing notes in class

  • In pairs, discuss with each other what your preferred platform to receive a word based message is that you both agree on and exchange the necessary info from each other to send/receive.
    • You and your partner don’t have to choose the same way to receive a message
    • Examples
      • snail mail 💌
      • an sms text
      • a signal text
      • a voice recording text of you reading the note aloud
      • email
      • instagram dm
      • reddit comment on an obscure subreddit
      • youtube comment on your favorite music video
  • Create a new .ipynb file and building off of, manipulating, and editing parts of the code we went through in class, create a poem or a note to share with your partner. Send it to them using their preferred medium platform.

To document and share your note

  • Take a photo or screenshot of your message embedded in the medium you sent it to your partner in. (Example: photo of a mailed letter or screenshot of a text or an audio file of you reading the note aloud)
  • Upload this documentation here:

Supplemental Coding Practice

Copy and paste the raw text linked below, written by Allison Parrish into a new .ipynb file you create called something like exercises.ipynb and go through the tasks in Jupyter Notebook.