w3resource

NumPy: Print the NumPy version in your system


Print NumPy Version

Write a NumPy program to print the NumPy version on your system.

Sample Solution:-

Python Code:

# Importing the NumPy library with an alias 'np'
import numpy as np

# Printing the version of NumPy installed
print(np.__version__)

Sample Output:

1.12.0

Explanation:

In the above code -

print(np.__version__): Accesses the __version__ attribute of the NumPy library, which holds a string representing the version number of the currently installed NumPy package. This line prints the version number.

NumPy version:

class numpy.lib.NumpyVersion(vstring): Parse and compare numpy version strings.

New in version 1.9.0.
Parameters vstring : str
NumPy version string (np.__version__).


For more Practice: Solve these Related Problems:

  • Write a script to print the NumPy version and verify if it meets a minimum required version.
  • Compare the printed NumPy version with the version obtained from pip freeze.
  • Create a function that logs the NumPy version along with the current date and time.
  • Print the NumPy version and then assert that it is greater than a specified version number.

Go to:


PREV : NumPy Array Object Exercises Home
NEXT : Convert List to 1D Array


Python-Numpy Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

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.