Bird
0
0

What does the abs() function do in Python?

easy📝 Conceptual Q1 of 15
Python - Standard Library Usage
What does the abs() function do in Python?
AReturns the remainder of division
BCalculates the square root of a number
CRounds a number to the nearest integer
DReturns the absolute value of a number
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of abs()

    The abs() function returns the distance of a number from zero, ignoring its sign.
  2. Step 2: Compare with other options

    Square root, rounding, and remainder are done by other functions/operators, not abs().
  3. Final Answer:

    Returns the absolute value of a number -> Option D
  4. Quick Check:

    abs() = absolute value [OK]
Quick Trick: abs() always gives positive distance from zero [OK]
Common Mistakes:
  • Confusing abs() with round()
  • Thinking abs() calculates remainder
  • Mixing abs() with sqrt()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes