Check sibling questions

How can we import a module in Python?

 

Answer:

There are 2 ways to import a module in python:

Using import

Syntax:

import <module_name1>[,<module_name2>,.....,<module_namen>]

Example:

import math,random

Using from

Syntax:

from <module_name> import <function1>[,<function2>,…<functionn>] 

Example:

from math import pi

Are ads bothering you?

CA Maninder Singh's photo - Expert in Practical Accounts, Taxation and Efiling

Made by

CA Maninder Singh

CA Maninder Singh is a Chartered Accountant for the past 12 years. He also provides Accounts Tax GST Training in Delhi, Kerala and online.