Saurav Jain (Open Source + Communities) Profile picture
Developer Community Manager @Apify โ€ข ex ๐Ÿฅ‘ Amplication โ€ขOpen Sourceโ€ข Web Scraping/Automation โ€ข AI โ€ข Python โ€ข JavaScript โ€ขGitHub โ€ข Node.js

Jul 12, 2021, 9 tweets

Seven Python Math Library Functions ๐Ÿงฎ ๐Ÿ

A beginner should know about these important functions, it will make your work easy!!

Thread ๐Ÿ˜๐Ÿงต

1โƒฃ ๐˜€๐—พ๐—ฟ๐˜

In python, to find the square root of any number ( 3 is the square root of 9 ) you don't have to use power operator.

There is a special function " sqrt " which square roots the number given it as a parameter :)

๐Ÿ”— Code

2โƒฃ ๐—ฝ๐—ผ๐˜„

In the above tweet, we have learned how to square root a given number.

A square root is actually a number raised to a power of 0.5

But what if we want 3 or something as power.

Here we use " pow(x,y) " it returns x raised to power y.

๐Ÿ”— Code

3โƒฃ ๐—ฐ๐—ฒ๐—ถ๐—น

ceil function in python is used to return the smallest integer greater than equal to the given number.

For ex- ceil(9.1) = 10 , ceil(9.0) = 9

๐Ÿ”—Code

4โƒฃ ๐—ณ๐—น๐—ผ๐—ผ๐—ฟ

floor function in python returns the largest integer smaller than or equal to the given number.

For ex- floor(9.9) = 9 , floor(9.1) = 9

๐Ÿ”— Code

5โƒฃ ๐—ณ๐—ฎ๐—ฐ๐˜๐—ผ๐—ฟ๐—ถ๐—ฎ๐—น

Yes, you read it correctly!!

You don't have to write a program for finding the factorial of a number.

It's just one line of code ;)

๐Ÿ”— Code

6โƒฃ ๐—ถ๐˜€๐—ป๐—ฎ๐—ป

While doing analysis of data of 1000s of entries, sometimes we have to check that which entry is empty or NaN ( Not a number)

To check this math library have " isnan " function.

It returns true if x is a NaN otherwise returns False!

๐Ÿ”— Code

7โƒฃ ๐—ฒ๐˜…๐—ฝ

In mathematical calculations, sometimes we have to find exponential of some number.

Don't worry you don't have to do calculations in python ;)

There is a simple function exp, which take number as input and gives the result!!

๐Ÿ”—Code

Hey all,

Hope you are learning something new from my threads daily.

If you like my content then please ReTweet the first tweet of the thread so that it can be reached to your connections too ๐Ÿ˜‰

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling