PYCS 02 - Arithmetic and Variables - Colaboratory
PYCS 02 - Arithmetic and Variables - Colaboratory
1 + 1
1 + 1 + 1
1 + 2 + 3 + 4
https://colab.research.google.com/drive/1Ek8Hlp9QZcNsXkVZD16ZJEMkICBnFCgI?usp=sharing#scrollTo=ukIrOqyi9ZwR&printMode=true 1/9
1/10/23, 1:14 PM PYCS 02 - Arithmetic and Variables - Colaboratory
1 + 10 + 100 + 1000 + 10000
1+10+100+1000+10000
11111
1 + 10 +100 + 1000 + 10000
11111
1 + 10 + 100 + 1000 + 10000
100 - 23
77
900 - 300 - 50
https://colab.research.google.com/drive/1Ek8Hlp9QZcNsXkVZD16ZJEMkICBnFCgI?usp=sharing#scrollTo=ukIrOqyi9ZwR&printMode=true 2/9
1/10/23, 1:14 PM PYCS 02 - Arithmetic and Variables - Colaboratory
100 - 23 + 7 - 4
100 - (23 + 7) - 4
33 * 12
396
2 * 10 - 4 + 3 * 6
2 * (10 - 4) + 3 * 6
20 / 5
12 / 5
2.4
https://colab.research.google.com/drive/1Ek8Hlp9QZcNsXkVZD16ZJEMkICBnFCgI?usp=sharing#scrollTo=ukIrOqyi9ZwR&printMode=true 3/9
1/10/23, 1:14 PM PYCS 02 - Arithmetic and Variables - Colaboratory
12 // 5
50 / 11
4.545454545454546
50 // 11
3.5 * 17.2
60.199999999999996
2.5 * 10.25 - 4.75 + 3.5 * 6.25
Comments
https://colab.research.google.com/drive/1Ek8Hlp9QZcNsXkVZD16ZJEMkICBnFCgI?usp=sharing#scrollTo=ukIrOqyi9ZwR&printMode=true 4/9
1/10/23, 1:14 PM PYCS 02 - Arithmetic and Variables - Colaboratory
# Most comments in Python start w/ an octothorpe (also known as the pound sign).
# You can have as many of these as you like as long as they start with '#'.
''' Multi-line comments in Python
can be created with 3 single quotes '''
"""
Three
double
quotes
is
also
ok
"""
Variables
number = 4
number
Variable Names
number
number5
number_5
variablename
a_long_name_is_ok
Another important point about variable names is that sales_tax = tax * purchase
they are case-sensitive. This means that lower-case
letters and upper-case letters are completely different Eyoas Bekele
2:51 PM Yesterday
in Python. For example, the following code block uses
2 different variable names. area_of_triangle = 1/2 * (base * height)
value = 50
Tobechukwu Obi
Value = 100
5:11 AM Today
Timothy James
8:58 PM Yesterday
number_five = 5
one_more_than_five = number_five + 1
Tobechukwu Obi
one_more_than_five
5:13 AM Today
circum_circle = diameter * pi
https://colab.research.google.com/drive/1Ek8Hlp9QZcNsXkVZD16ZJEMkICBnFCgI?usp=sharing#scrollTo=ukIrOqyi9ZwR&printMode=true 7/9
1/10/23, 1:14 PM PYCS 02 - Arithmetic and Variables - Colaboratory
Try It!
Variables and Calculations
tax = 0.06
purchase = 7.98
height = 8.2
base = 3.5
# the area of a triangle is one half its base times its height.
pi = 3.14
diameter = 19
# circumference is the diameter multiplied by pi.
https://colab.research.google.com/drive/1Ek8Hlp9QZcNsXkVZD16ZJEMkICBnFCgI?usp=sharing#scrollTo=ukIrOqyi9ZwR&printMode=true 8/9
1/10/23, 1:14 PM PYCS 02 - Arithmetic and Variables - Colaboratory
https://colab.research.google.com/drive/1Ek8Hlp9QZcNsXkVZD16ZJEMkICBnFCgI?usp=sharing#scrollTo=ukIrOqyi9ZwR&printMode=true 9/9