Skip to content
Home » abs() Function in Python for Integer

abs() Function in Python for Integer

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

abs() Function in Python for Integer

# Program to find absolute value of number

#input from user
num = int(input('Enter the integer number: '))

#absolute  value
val = abs(num)

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

Output:

Enter the integer number: -4
Absolute value of number is = 4

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

Similar Code : Python Program to Find Perfect Squares in Given Range