From the course: Python Functions for Data Science
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Python abs() function - Python Tutorial
From the course: Python Functions for Data Science
Python abs() function
- [Instructor] A built in Python function that comes in handy in computational work is Abs. The Abs function takes in a numeric value as input and returns the absolute value of that input. I'll be walking through a few examples to illustrate how the Abs function can be used. To find the absolute value of the integer 70, I can call the Abs function and pass in 70 as input. It would look like this. Now to find the absolute value of the integer -65, I can call the Abs function and pass a -65 as input. It will look like this. Now say that I have a variable named temp1 containing the float 98.6. To compute the absolute value of temp1, I can call the Abs function and pass in temp1 as input. It will look like this. Then say that I have another variable named temp2 containing the float -37.1. To compute the absolute value of temp2, I can call the Abs function and pass in temp2 as input. It will look like this. Next, say that I…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.