What happens if you import a same module in Python twice and the module contains code print("hello")?
Experience Level: Junior
Tags: Python
Answer
The message "hello" will be displayed only once because the module loads only once even if it was imported multiple times.
Related Python job interview questions
How do you define a function in Python?
Python JuniorHow can you display all modules that are currently loaded in your Python program?
Python JuniorHow do you find out in what folder is the Python imported module stored?
Python JuniorWhen would you use the print() function in Python?
Python JuniorWhat is the print() function good for in Python?
Python Junior