-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path20-Modules.py
More file actions
33 lines (23 loc) · 743 Bytes
/
20-Modules.py
File metadata and controls
33 lines (23 loc) · 743 Bytes
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
#Python Modules
'''
In Python we are able to write a long program and save as a module.
This is known as creating a script. We are able to import modules
across modulesand into the Python interpreter. This negates the
need to keep repeating ourselves.
DRY!....Don't repeat yourself
'''
import ModuleExample
ModuleExample.add(4,5.5)
#We can import a module by renaming it as follows:
# import module by renaming it
import ModuleExample as m
print("The addition is ",m.add(4,5.5))
#Python import statement
# import statement example
# to import standard module math
import math
print("The value of pi is", math.pi)
#Python from...import statement
# import only pi from math module
from math import pi
print("The value of pi is", pi)