Concepts:
>>> tel = {'jack': 4098, 'sape': 4139}
>>> tel['guido'] = 4127
>>> tel
{'jack': 4098, 'sape': 4139, 'guido': 4127}
>>> tel['jack']
4098
>>> del tel['sape']
>>> tel['irv'] = 4127
>>> tel
{'jack': 4098, 'guido': 4127, 'irv': 4127}
>>> list(tel)
['jack', 'guido', 'irv']
>>> sorted(tel)
['guido', 'irv', 'jack']
>>> 'guido' in tel
True
>>> 'jack' not in tel
False
$$0 \le m < b$$
For example: $$n \% 1 = 0$$ $$10 \% 3 = 1$$ $$3 \% 2 = 1$$ $$5 \% 3 = 2$$
$$a \equiv b \pmod c$$ Means that $$a \% c = b \% c$$
For example: $$9 \equiv 5 \pmod 4$$ $$4 \equiv 2 \pmod 2$$ $$3 \equiv 5 \pmod 2$$
If a1 ≡ b1 (mod n) and a2 ≡ b2 (mod n), or if a ≡ b (mod n), then:
We can compute with remainders.
def checksum(A):
cksum = 0
for a in A:
cksum += a
return cksum % 101
Will overflow if integers are big
def checksum(A):
cksum = 0
for a in A:
cksum += a % 101
return cksum % 101
Will NOT overflow even if integers are big.
def checksum(A):
cksum = 0
for a in A:
cksum += a % 101
cksum %= 101
return cksum
Will NOT overflow even if integers are big.