Python Basics · Beginner · 35 XP · about 4 min
Write a function called absolute(n) that returns the absolute value of a number (without using Python's built-in abs() function).
The absolute value of a number is its distance from zero, always positive.
absolute(5) # Returns 5 absolute(-5) # Returns 5 absolute(0) # Returns 0 absolute(-100) # Returns 100
abs() functionReady?
Accept the challenge to start writing. A small timer counts the time this page is in view.
Output appears here.