EEB125 Week 1: Computation, Python, and JupyterHub#

Quick Facts#

  • Name: Karen Reid

  • Professor, Teaching Stream in the Department of Computer Science

  • I primarily teach systems programming and operating systems. I.e. Low-level, how does the computer really work kind of stuff.

What is programming?#

A computer program is a set of instructions for a computer to execute.

Just as humans have languages like English to communicate with each other, a programming language is a language that allows humans to communicate these instructions to a computer.

Python!#

In this course, we’ll be using the Python programming language.

Python logo

Why Python?#

Python is…

  • beginner friendly (code looks a lot like English)

  • lots of built-in functionality

  • powerful data science and data visualization libraries (e.g. numpy, pandas, plotly)

  • very commonly used in both academia and industry

Writing Python code#

Next week, we’ll start going over the basics of Python programming, but for now, think of Python code as a sequence of very precise instructions that your computer can understand.

my_name = "Karen"
my_students = 400 + 300

print(f"Wow {my_name}, you're teaching {my_students} students. That's a big class!")

my_students = my_students + 120 + 85

print(f"Actually {my_name}, it's more like {my_students}")

Notebooks!#

Traditionally, Python code was written in .py files, called Python modules.

Image of Python code

Notebooks!#

In this course, we’ll use Jupyter notebooks to write Python code.

Notebooks let us mix:

  • Python code

  • Output of running the code

  • Text (including nice formatting)

  • Images

  • …and more!

Notebooks!#

Fun fact: Jupyter, the software that lets us create notebooks, is written in Python!

Jupyter logo

Do I need to download and install Python and Jupyter?#

Meme about software installation wizard

No software installation required!#

In this course, we’ll be using JupyterHub (https://jupyter.utoronto.ca), which runs Python and Jupyter for us online.

  • You can login to JupyterHub from anywhere with an Internet collection

  • All of your files are stored “in the cloud”

  • Runs Python code “in the cloud”

JupyterHub Demo!#

Two ways of accessing JupyterHub:

  1. Go to https://jupyter.utoronto.ca

  2. Go to any notebook on our course website (https://uoftcompdsci.github.io/eeb125-20251/) and click on the little rocket icon:

    Image of JupyterHub launch from course website

Example: Let’s check your intuition#

  • What do you think the following code will do?

  • What types of data are we working with?

  • What is the most mysterious thing about the code right now?

  • What seems obvious?

sentence = "Programming in EEB125 will be fun."
words = sentence.split()
sum = 0

for word in words:
    sum = sum + len(word)

average = sum/len(words)
print(f"Average word length is {average}")

Learning and Learning to Program. Some things to remember#

  • Programming languages are actually for people, not for computers :)

  • Learning a new programming language is similar to learning a new (written) human language, but … easier

    • Vocabulary is much, much smaller

    • Syntax/Grammar are much simpler

    • The main limitation is that the computer is more strict

    • The real barrier is understanding what you want to do and explaining that in a clear non self-contradictory way

  • Learning to read code is perhaps more important that learning to write code:

    • Data Science tasks rarely start from a blank page

    • You use, assimilate, and adapt the code and ideas of others

    • Quite often, you are in a “menu in an exotic restaurant” situation, and that’s okay!

Some Active (Self-)Learning Strategies#

  • Activating Prior Knowledge

  • Distributing Practice (not cramming!) and Interleaving (not creating interruptions!)

  • Elaborative rehearsal: rephrasing, finding examples, integrating with other constructs, organizing in a meaningful way

From strategies to tactics#

  • Reading your own code and the code of others, highlight and annotate it (notebooks are perfect for that)

    • Use markdown blocks to write down topic sentences and paragraphs,

    • Always assume you will need to reread your code and that you will you remember nothing

    • Dealing with the complex blocks of code you don’t understand just yet, try to write down high-level explanations in plain language

      • what does it do?

      • what does it take as an input and produce as an output?

  • Distributed practice and elaborative rehearsal:

    • Read the lab and homework at the beginning of the week. If you have time, make comments

    • Look at the previous homework to find useful chunks

    • Regularly repeat main commands, functions, and constructs in context

    • For example, modify a bit chunks from previous homework (What if I change 5 to 6, a number to a character, add another variable?)

    • Make notes on connections between terminology and Python syntax, between different ways of writing the same code