forked from navinreddy20/Python-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
18 Import Math Functions in Python
50 lines (49 loc) · 1.12 KB
/
18 Import Math Functions in Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Code
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> x = sqrt(25)
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
x = sqrt(25)
NameError: name 'sqrt' is not defined
>>> import math
>>> x = math.sqrt(25)
>>> x
5.0
>>> x = math.sqrt(15)
>>> x
3.872983346207417
>>> print(math.floor(2.9))
2
>>> print(math.ceil(2.2))
3
>>> 3 ** 2
9
>>> print(math.pow(3,2))
9.0
>>> print(math.pi)
3.141592653589793
>>> print(math.e)
2.718281828459045
>>> m.sqrt(25)
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
m.sqrt(25)
NameError: name 'm' is not defined
>>> import math as m
>>> math.sqrt(25)
5.0
>>> m.sqrt(25)
5.0
>>>
=============================== RESTART: Shell ===============================
>>> math.sqrt(25)
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
math.sqrt(25)
NameError: name 'math' is not defined
>>> from math import sqrt, pow
>>> pow(4,5)
1024.0
>>> help('math')
>>>