Skip to content
Home » abs() in Python for Floating Number

abs() in Python for Floating Number

Learn about abs() in Python for Floating Number in the below code example. Also, refer the comments in the code snippet to get a detailed view about what’s actually happening.

abs() in Python for Floating Number

# Python program to find absolute value of number

# input from user
num = float(input('Enter a float number: '))

#absolute value
val = abs(num)

# result
print('Absolute value of number is =',val)

Output:

Enter a float number: -2.6
Absolute value of number is = 2.6

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Code : abs() Function in Python for Integer