1 + 1
2
1 + 4
5
SHIFT
+ ENTER
D
, D
1 + 3
4
1 - 3
-2
4*5
20
4 / 5
0.8
3^4
7
To perform exponentiation, use **
or the pow
function instead of ^
:
3**4
81
pow(3,4)
81
Using the standard division /
will return what is called a float.
5 / 2
2.5
4 / 2
2.0
2.0 ** 1000
1.0715086071862673e+301
2**1000
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
2.0**1500
--------------------------------------------------------------------------- OverflowError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_23904\2939582728.py in <module> ----> 1 2.0**1500 OverflowError: (34, 'Result too large')
2**1500
35074662110434038747627587960280857993524015880330828824075798024790963850563322203657080886584969261653150406795437517399294548941469959754171038918004700847889956485329097264486802711583462946536682184340138629451355458264946342525383619389314960644665052551751442335509249173361130355796109709885580674313954210217657847432626760733004753275317192133674703563372783297041993227052663333668509952000175053355529058880434182538386715523683713208549376
This is some text within a Markdown cell.
This is some text in a code cell, and will throw an error
File "C:\Users\Luke\AppData\Local\Temp\ipykernel_23904\3831271697.py", line 1 This is some text in a code cell, and will throw an error ^ SyntaxError: invalid syntax
We can double-click on a markdown cell to edit it.
We can create headings using hashtags, #
:
# Heading
gives a top-level heading## Sub-heading
gives a sub-heading### Sub-sub-heading
gives a sub-sub-headingWe can generate bulleted (un-numbered) using a space and hyphen:
We can also nest lists:
We can also create numbered lists using 1.
, 2.
, etc.
5 / 2
2.5
4 / 2
2.0
The normal division symbol /
will always return a floating point number.
Sometimes, we would prefer to return an integer number. We can this using the //
operation:
4 // 2
2
5 // 2
2
The integer division //
will always return the quotient from performing long division.
We can get the remainder from integer division using %
. This is called modular division.
5 % 2
1
123 % 7
4
123 // 7
17
The above calculation demonstrates that $123 = 7\cdot 17 + 4$.
(123/7 - 17) * 7
4.000000000000011
8 / 3
2.6666666666666665
Very often, we want to perform operations on some input that might change. We can define variables using the =
symbol:
n = 130
We can recall the value of this variable with the variable name, n
:
n
130
n // 7
18
n % 7
4
n
130