Lecture Week 1 Mon 9/30#
type(3)
int
type(0.1)
float
type(True)
bool
type("text")
str
type('text')
str
7/2
3.5
7//2
3
7%2
1
1+1
2
2*3
6
2**3
8
3 == 3
True
3 == 2
False
0.8 - 0.7 == 0.1
False
0.8 - 0.7
0.10000000000000009
a = 0.8 - 0.7
b = 0.1
abs(a-b)<1e-12
True
for i in range(3):
print(i)
0
1
2
# range(start[default=0], stop, step[default=1])
for i in range(2,9,3):
print(i)
2
5
8
x = [1, 2, 3]
type(x)
list
x = [1, 2, 3.2, True, "test"]
for elem in x:
print(elem)
1
2
3.2
True
test
# what is the output
# (1) 4, 8
# (2) 4, 8, 16
x = 2
while x < 10:
x = x*2
print(x)
4
8
16