February 2019
Beginner to intermediate
319 pages
6h 56m
English
Write the corresponding method __ne__, which checks if two FieldElement objects are not equal to each other.
classFieldElement:...def__ne__(self,other):# this should be the inverse of the == operatorreturnnot(self==other)
Solve these problems in F57 (assume all +’s here are +f and –’s here are –f):
44 + 33
9 – 29
17 + 42 + 49
52 – 30 – 38
>>>prime=57>>>((44+33)%prime)20>>>((9-29)%prime)37>>>((17+42+49)%prime)51>>>((52-30-38)%prime)41
Write the corresponding __sub__ method that defines the subtraction of two FieldElement objects.
classFieldElement:...def__sub__(self,other):ifself.prime!=other.prime:raiseTypeError('Cannot subtract two numbers in different Fields')# self.num and other.num are the actual values# self.prime is what we need to mod againstnum=(self.num-other.num)%self.prime# we return an element of the same classreturnself.__class__(num,self.prime)
Solve the following equations in F97 (again, assume ⋅ and exponentiation are field versions):
95 ⋅ 45 ⋅ 31
17 ⋅ 13 ⋅ 19 ⋅ 44
127 ⋅ 7749
>>>prime=97>>>(95*45*31%prime)23>>>(17*13*19*44%prime)68>>>(12**7*77**49%prime)63
For k = 1, 3, 7, 13, 18, what is this set in F19?
Do you notice anything about these sets?
>>>prime=19>>>forkin(1,3,7,13,18):
Read now
Unlock full access