173. Dynamic Importing of Modules
import importlib
module_name = "math"
math_module = importlib.import_module(module_name)
print(math_module.sqrt(16)) # Output: 4.0import importlib
module_name = "math"
function_name = "pow"
math_module = importlib.import_module(module_name)
power_function = getattr(math_module, function_name)
print(power_function(2, 3)) # Output: 8.0Last updated