+ 2
How to use import math in python
11 odpowiedzi
+ 7
Python has also a built-in module called math, which extends the list of mathematical functions.
To use it, you must import the math module:
import math
And use it like:
math.sqrt(4)
or the famous:
math.pi
+ 2
Or use can import like this:
from math import *
sqrt(4)
pi
+ 2
import math
print(pow(3,4))
#Can use like this too
+ 2
Eashan Morajkar Is ceil function too works like that?
+ 2
Eashan Morajkar ok this will work
import math
print(math.sqrt(25))
+ 2
Eashan Morajkar just check the sqrt case pls
+ 2
Yes so the second one is correct, isn't it?
+ 1
Atul That's not a math function use can use pow function without math
print(pow(3,4))
0
@Atul ceil function requires the math module
0
Atul Your sqrt case will work because you're importing the math module and it will print 5.0
0
Atul yes it will