You are on page 1of 1

Module:

### sample_module.py
#Declare a Function
def greeting(name):
print("Hello, " + name)

#Declare a Dictionary Variable


person1 = {
"name": "John",
"age": 36,
"country": "Norway"
}

import sample_module as sm
sm.greeting("Developers")
sm.person1["age"]

### Built-in Modules


There are several built-in modules in Python. We can directly used the built-in
methods with out importing its modules.
if they are available in global namespace. Example Map, Filter etc.
#Get all the builtins in Python
dir(__builtins__)

Some buil-in methods are need to be imported like time, datetime etc.
Ex-
import time
time.sleep(5)

import sys
#Find out all the sys built in modules
sys.builtin_module_names

#Find out where sys is lcoated


sys.prefix

### Using the dir() Function


We can use dir() built-in function to list all the function names (or variable
names) in a module.

import time
dir(time)
help(time.sleep)

You might also like