Python


Question 1. Write a function monexp(n) that returns the partial sum

Me(N) = ΣNk=1 (-1)k/k2.

Question 2. Representing a fraction as a list of two ints, e.g., 2/3 is represented as [2,3], write a function norm() that takes a list of two ints and returns a normalised form, e.g., norm( [-9, 12] ) returns [-3,4].

Question 3. Representing a complex number as a list of two floats, e.g., 2 + 3i be¬comes [2,3], write functions cmul 0 and cdiv() that multiplies and divides two complex numbers (in our representation).

Question 1. Write a function nprimes (n) that returns the number of prime numbers less than n.

Question 2. Write a function pprimes(n) that returns the product of the first n prime numbers.

Question 3. Write a function euprod(n) that returns the partial product
Π(1-1/p2)
p prime

Question 4. A positive integer is called square-free if it is not divisible by any perfect square other than 12. Write a function issquarefree (q) that returns True if q is square-free and False otherwise.

Question 5. A positive integer is called a perfect number if it is the sum of all its factors. Write a function isperfect(q) that returns True if q is perfect and False otherwise. Note: you may not simply check the input against known perfect numbers.

• No import is allowed (and similar builtins: exec, execf ile, __import_).

• Your program must not produce spurious output (i.e. no print statements please). Please clean up your debugging and test cases before submitting.

Request for Solution File

Ask an Expert for Answer!!
Mathematics: Python
Reference No:- TGS01100378

Expected delivery within 24 Hours