Wednesday, January 21st, 2026¶

Getting started with Jupyter notebook¶

  • We can execute a cell using SHIFT + ENTER.
  • We can add a new cell using the plus symbol in the top-left corner. Alternatively, you can select a cell and hit A to add a cell above, or B to add a cell below.
  • We can delete a cell by selecting the cell, then hitting D, D.
In [21]:
1 + 5
Out[21]:
6
In [9]:
7 - 1
Out[9]:
6

Arithmetic operations¶

Addition:

In [22]:
1000 + 200123
Out[22]:
201123

Subtraction:

In [23]:
123 - 456
Out[23]:
-333

Multiplication:

In [24]:
123*456
Out[24]:
56088

Division:

In [25]:
10 / 2
Out[25]:
5.0

Exponentiation:

In [26]:
3^2
Out[26]:
1

To perform exponentiation, use ** or the pow function instead of ^:

In [27]:
3**2
Out[27]:
9
In [28]:
pow(3,2)
Out[28]:
9

Using the standard division / will return what is called a float.

In [30]:
33 / 11
Out[30]:
3.0
In [31]:
1/3
Out[31]:
0.3333333333333333
In [ ]:
 

Integers vs floats¶

  • integers = numbers without any decimal point
  • floats = numbers with a decimal point
  • operations on integers are exact
  • operations on floats are approximate
  • integers can be arbitrarily large, but floats are represented only within a finite range.
In [33]:
12345678901234567890 + 1
Out[33]:
12345678901234567891
In [34]:
12345678901234567890.
Out[34]:
1.2345678901234567e+19
In [57]:
2**1200
Out[57]:
17218479456385750618067377696052635483579924745448689921733236816400740691241745619397484537236046173286370919031961587788584927290816661024991609882728717344659503471655990880884679896520055123906467064419056526231345685268240569209892573766037966584735183775739433978714578587782701380797240772477647874555986712746271362892227516205318914435913511141036261376
In [58]:
2.0 ** 1200
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
Cell In[58], line 1
----> 1 2.0 ** 1200

OverflowError: (34, 'Result too large')

Markdown¶

Markdown is a markup language used for creating formatted text. In Jupyter, we create Markdown cells to hold this text.

A Code cell can be converted to a Markdown cell using the dropdown menu in the top menu bar. Alternatively, we can select a Code cell and hit the M key to convert it to a Markdown cell. To convert back to a Code cell, we can again use the dropdown menu or select the cell and hit the Y key.

Once we've written our desired Markdown, we can execute the cell (e.g. by hitting SHIFT + ENTER) to render the Markdown. If we need to edit the Markdown cell, we can double click on it, or select the cell and hit ENTER.

In [59]:
This is a code cell. Anything in here is treated as Python code.
  Cell In[59], line 1
    This is a code cell. Anything in here is treated as Python code.
              ^
SyntaxError: invalid syntax

This is a Markdown cell. Anything in here is treated as text.

Within a Markdown cell, We can create headings using hashtags, #:

This is a top-level heading¶

Sub-headings (and sub-sub-headings, etc.) can be created using multiple hashtags, ## (or ###, etc.).

This is a sub-heading¶

This is a sub-sub-heading¶

This is a sub-sub-sub-heading¶