Bird
Raised Fist0

What will be the output of this code?

medium📝 Predict Output Q4 of Q15
Python - Modules and Code Organization
What will be the output of this code?
import random
print(type(random))
A<class 'module'>
B<class 'function'>
Crandom
DError: module not found
Step-by-Step Solution
Solution:
  1. Step 1: Understand what 'random' is after import

    When you import a module, its type is module.
  2. Step 2: Check the output of type(random)

    The output will be <class 'module'> indicating it is a module object.
  3. Final Answer:

    <class 'module'> -> Option A
  4. Quick Check:

    Importing module type = <class 'module'> [OK]
Quick Trick: Imported modules are of type 'module' [OK]
Common Mistakes:
MISTAKES
  • Expecting a function type
  • Thinking it prints the module name
  • Assuming import fails without error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes