Week 1, Wed, 4/2#
0.8 - 0.7 == 0.1
False
a = 0.8 - 0.7
b = 0.1
abs(a-b)<1e-9
True
4%4
0
Method 1
x = []
for i in range(1,1001):
if i%17 == 0:
x.append(i)
len(x)
58
Using list comprehension
len([i for i in range(1,1001) if i%17 ==0])
58
Method 2, use range and step size
for i in range(17,100,17):
print(i)
17
34
51
68
85
len(range(17,100,17))
5
Method 3, use math
1000//17
58
a = [1,2,3]
b = a
a[1] = 0
a
[1, 0, 3]
b
[1, 0, 3]