We can import multiple modules in one line using comma-separated import statements.
This method is widely used and straightforward for importing multiple modules in one line. You just list the modules you need to import, separated by commas, within one import statement.
For example:
import random, math, statistics
This line imports the random , math, and statistics modules. You can then directly utilize these modules in your code by referencing their names.
import_multiple_modules.py
import random, math, statistics
print('Random Integer ', random.randint(1, 10))
print('PI : ', math.pi)
print('mean : ', statistics.mean([2, 3, 5, 7, 11]))
Output
Random Integer 8 PI : 3.141592653589793 mean : 5.6
Previous Next Home
No comments:
Post a Comment