What is the syntax to import modules?

What is a module?
A module is a Python program that contains a group of related functions. After you import a module, its functions become available for use in your program. All module sets are contained in Python’s standard library. The library can be found here.

#to import one module
import <module name> 

#to import multiple modules
import <module name>, <module name>, <module name>...etc

Some commonly used modules include: random, sys, os, math.

#example
import random
for i in range(5):
    print(random.randint(1,10))

#output
4
2
6
7
8
Advertisements