CBSE Class 11 Computer Science Question 7 of 63

Introduction to Python Modules — Question 7

Back to all questions
7
Question

Question 7

Assertion (A): Python modules are .py files that contain Python code.

Reasoning (R): The import statement allows you to import all the functions from a module into your code.

  1. Both A and R are true and R is the correct explanation of A.
  2. Both A and R are true but R is not the correct explanation of A.
  3. A is true but R is false.
  4. A is false but R is true.
Answer

Both A and R are true and R is the correct explanation of A.

Explanation
A module is created as a python (.py) file containing a collection of function definitions, classes and variables. The import statement can be used to import a module. It is the simplest and most common way to use modules in our code. It provides access to all attributes (like variables, constants etc) and methods or functions present in the module.