T4Tutorials .PK

NSCT – Modules, Packages & Libraries MCQs

1. What is a module in programming?

(A) A type of loop


(B) A file containing code that can be reused


(C) A variable


(D) A function




2. What is the main purpose of using modules?

(A) To store variables


(B) To create loops


(C) To organize code and promote reuse


(D) To handle errors




3. What is a package in programming?

(A) A collection of modules organized in a directory


(B) A single function


(C) A loop structure


(D) A variable type




4. Which of the following is a benefit of using packages?

(A) Memory allocation


(B) Faster execution


(C) Code organization and namespace management


(D) Exception handling




5. What is a library in programming?

(A) A collection of pre-written modules or functions for reuse


(B) A type of variable


(C) A loop


(D) A conditional statement




6. Which of the following allows importing code from other files?

(A) Using loops


(B) Importing a module


(C) Declaring a variable


(D) Creating a function




7. How can a module be reused in another program?

(A) By copying code manually


(B) By importing it


(C) By defining a loop


(D) By creating a variable




8. Which of the following helps avoid name conflicts between modules?

(A) Packages


(B) Loops


(C) Functions


(D) Variables




9. What is a standard library?

(A) A variable type


(B) A user-defined function


(C) A loop structure


(D) A collection of built-in modules provided by the programming language




10. Which of the following is a third-party library?

(A) A library created by external developers for reuse


(B) A built-in module


(C) A function in the main program


(D) A loop structure




11. What is the main benefit of using libraries?

(A) Allocates memory


(B) Creates loops


(C) Reduces coding effort and saves time


(D) Stores variables




12. Which keyword is commonly used to access a module in a program?

(A) include


(B) import


(C) using


(D) define




13. What is the difference between a module and a package?

(A) No difference


(B) A module is a loop; a package is a function


(C) A module stores variables; a package stores loops


(D) A module is a single file; a package is a collection of modules




14. Which of the following is true about libraries?

(A) They provide pre-written code for common tasks


(B) They store only variables


(C) They are used only in loops


(D) They cannot be reused




15. What is the purpose of the __init__ file in a package?

(A) To define loops


(B) To store variables


(C) To indicate that the directory is a package


(D) To handle exceptions




16. Can a module import another module?

(A) Yes


(B) No


(C) Only in loops


(D) Only in functions




17. Which of the following is an example of a Python standard library?

(A) Math


(B) Custom module


(C) Loop function


(D) User-defined variable




18. What is the main advantage of using modules and packages?

(A) Error handling


(B) Faster compilation


(C) Memory allocation


(D) Code modularity, reuse, and organization




19. Which of the following is used to install third-party libraries in Python?

(A) import


(B) pip


(C) include


(D) define




20. What is a namespace in the context of modules and packages?

(A) A loop structure


(B) A container that holds identifiers like variable and function names to avoid conflicts


(C) A type of library


(D) A memory location




Exit mobile version