Vidyalelo
Python · Q25

Python Introduction and basic

Programming · Python · question 25

Q25

What is the role of the import statement in Python?

A.
To declare variables
B.
To define classes
C.
To import external modules
Answer
D.
To output text to the console

Answer: Option C

Solution

Answer: Option C
Solution:
In Python, the import statement is used to import external modules.
The import statement allows you to access functionality defined in external modules and use it in your Python program. Modules are Python files that contain Python code, including variables, functions, and classes. By importing modules, you can reuse code, organize related functionality, and extend the capabilities of your program. Python provides a rich ecosystem of built-in and third-party modules that cover a wide range of tasks and domains, including math, file I/O, networking, and more. The import statement is essential for leveraging this existing functionality and building powerful Python applications.