Test Series - python

Test Number 78/108

Q: What is returned by math.ceil(3.4)?
A. 3
B. 4
C. 4.0
D. 3.0
Solution: The ceil function returns the smallest integer that is bigger than or equal to the number itself.
Q: What is the value returned by math.floor(3.4)?
A. 3
B. 3.4
C. 4
D. -3.0
Solution: The floor function returns the biggest number that is smaller than or equal to the number itself.
Q: What will be the output of print(math.copysign(3, -1))?
A. 3
B. 3.4
C. 4
D. -3.0
Solution: The copysign function returns a float whose absolute value is that of the first argument and the sign is that of the second argument.
Q: What is displayed on executing print(math.fabs(-3.4))?
A. 3
B. 3.4
C. 4
D. -3.0
Solution: A negative floating point number is returned as a positive floating point number.
Q: Is the output of the function abs() the same as that of the function math.fabs()?
A. sometimes
B. always
C. never
D. none of the mentioned
Solution: math.fabs() always returns a float and does not work with complex numbers whereas the return type of abs() is determined by the type of value that is passed to it.
Q: What is the value returned by math.fact(6)?
A. 720
B. 6
C. [1, 2, 3, 6]
D. error
Solution: NameError, fact() is not defined.
Q: What is the value of x if x = math.factorial(0)?
A. 0
B. 1
C. error
D. none of the mentioned
Solution: Factorial of 0 is 1.
Q: What is math.factorial(4.0)?
A. 24
B. 1
C. error
D. none of the mentioned
Solution: The factorial of 4 is returned.
Q: What will be the output of print(math.factorial(4.5))?
A. 24
B. 120
C. error
D. 24.0
Solution: Factorial is only defined for non-negative integers.
Q: What is math.floor(0o10)?
A. 8
B. 10
C. 0
D. 9
Solution: 0o10 is 8 and floor(8) is 8.

You Have Score    /10