w3resource

Python: Import built-in array module and display the namespace of the said module


1. Import Built-in Array Module and Display Namespace

Write a Python program to import a built-in array module and display the namespace of the said module.

Sample Solution:

Python Code:

import array
for name in array.__dict__:
    print(name)

Sample Output:

__name__
__doc__
__package__
__loader__
__spec__
_array_reconstructor
ArrayType
array
typecodes 

Flowchart

Flowchart: Import built-in array module and display the namespace of the said module

For more Practice: Solve these Related Problems:

  • Write a Python program to import the 'array' module and print its dir() output to show all available functions and attributes.
  • Write a Python program that imports the array module and lists only the callable functions in its namespace.
  • Write a Python program to import the built-in array module and display its __doc__ string to understand its functionality.
  • Write a Python program to import the array module and use the vars() function to display its namespace dictionary.

Python Code Editor:

Contribute your code and comments through Disqus.

Previous: Python Class exercises.
Next: Write a Python program to create a class and display the namespace of the said class.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.