Q8
Which built-in function is used to calculate the absolute value of a number?
A.
abs()
AnswerB.
absolute()
C.
val_abs()
D.
calculate_abs()
Answer: Option A
Solution
Answer: Option A
Solution:
The correct answer is Option A: abs().The abs() function in Python is used to calculate the absolute value of a number.
It returns the magnitude of a numeric value without regard to its sign.
For example:
print(abs(-5)) # Output: 5
print(abs(3.14)) # Output: 3.14