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
Ato add a cell above, orBto add a cell below. - We can delete a cell by selecting the cell, then hitting
D,D.
1 + 5
6
7 - 1
6
Arithmetic operations¶
Addition:
1000 + 200123
201123
Subtraction:
123 - 456
-333
Multiplication:
123*456
56088
Division:
10 / 2
5.0
Exponentiation:
3^2
1
To perform exponentiation, use ** or the pow function instead of ^:
3**2
9
pow(3,2)
9
Using the standard division / will return what is called a float.
33 / 11
3.0
1/3
0.3333333333333333
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.
12345678901234567890 + 1
12345678901234567891
12345678901234567890.
1.2345678901234567e+19
2**1200
17218479456385750618067377696052635483579924745448689921733236816400740691241745619397484537236046173286370919031961587788584927290816661024991609882728717344659503471655990880884679896520055123906467064419056526231345685268240569209892573766037966584735183775739433978714578587782701380797240772477647874555986712746271362892227516205318914435913511141036261376
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.
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.).