## Register Now

It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways

## Abs() and Round() in Python | Python for Data Science |Day 10

Hello, Python gang!
The Data Monk is back with a new agenda for today. Let’s stick to the abs() and round() in Python functions for the discussion today. The two functions, abs() and round() in Python are used in the mathematical aspects of Python. They are very easy to understand. Just follow along as we hop on our journey.

• abs()

As you must have guessed already from the meme, the absolute value of a number is the modulus of a number, which implies that it can never be negative.

In Python, we use the abs() function to find the modulus of integers, floating point numbers and even complex numbers.

Please open your IDEs or notebooks to try the lines of code below and compare your outputs with ours:

Positive integer:

Positive float number:

Negative integer:

Negative float number:

Complex number:

For the last line of code, the absolute value of the complex number is taken as its magnitude.

z = a + ib

i.e. square root of a and b.

• Round()

The round() function rounds the given number to the specified number of digits and   returns a float number.

We can also specify the number of digits upto which it should be rounded. Look at the line of code below:

Attempt the questions below to understand abs() and round(). You can also refer to https://www.geeksforgeeks.org/abs-in-python/ for the functions.

Do practice these questions on your own before seeking aid from our provided solutions.

Alright, Pyfam. That’s the end of this tutorial. We will be back with another interesting topic. Stay with us for the rest of the series. Happy coding!

We have covered 40+ complete Data Science company interviews from the candidates who cracked these interviews.
Data Science Companies interview questions
Complete Set of e-books from The Data Monk
Understand some of the very complex topics in Analytics which are asked in most of the interviews
The Data Monk Top Articles
How to become a Data Scientist? Complete study material, free resources and websites to practice
Become a Data Scientist
Make your profile on our website and practice at least 5-7 questions per day. Be a part of ~2000 Analytics expert

Article By,
Yashika Khurana
Intern | The Data Monk