Calculate Absolute Value

Calculate Absolute Value

Tags: Basics

Credit: CodingChallenge

Difficulty: Beginner

Type: Text

Category: Practice

Time Allowed: 5 s

Description:

Write a function that takes a number and returns its absolute value using built-in functions. This problem is designed to help you practice using built-in functions for calculating absolute values. The function should accept one parameter and return the absolute value.

Constraints:

  • The input will be an integer or float.
  • The function should return the absolute value of the number.
  • Use built-in functions like abs().

Example:

  • Input: -5
  • Output: 5

Test Case Input Expected Output
1 -5 5
2 3 3
3 0 0
4 -2.5 2.5
5 7.5 7.5

Please register or login to submit solutions to challenges.