Certified Associate in Python Programming (PCAP) — Question 2

Can a module run like regular code?

Answer options

Correct answer: A

Explanation

The correct answer is A because a module in Python can indeed execute as regular code and can distinguish its execution context based on whether it is being run directly or imported. Option B is incorrect as the behavior of modules has been consistent across Python versions, while option C is wrong because modules can differentiate their behavior. Option D is also incorrect since modules can be executed directly.