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.