Q: What does the function math.frexp(x) return?
Solution: It returns a tuple with two elements. The first element is the mantissa and the second element is the exponent.
Q: What is the result of math.fsum([.1 for i in range(20)])?
Solution: The function fsum returns an accurate floating point sum of the elements of its argument.
Q: What is the result of sum([.1 for i in range(20)])?
Solution: There is some loss of accuracy when we use sum with floating point numbers. Hence the function fsum is preferable.
Q: What is returned by math.isfinite(float(‘inf’))?
Solution: float(‘inf’) is not a finite number.
Q: What is returned by math.isfinite(float(‘nan’))?
Solution: float(‘nan’) is not a finite number.
Q: What is x if x = math.isfinite(float(‘0.0’))?
Solution: float(‘0.0’) is a finite number.
Q: What is the value of x if x = math.ldexp(0.5, 1)?
Solution: The value returned by ldexp(x, y) is x * (2 ** y). In the current case x is 1.0.
Q: What is returned by math.modf(1.0)?
Solution: The first element is the fractional part and the second element is the integral part of the argument.
You Have Score    | /8 |