How to check the version of Python?

To check the version of Python you have installed on your computer, you can use the python --version or python -V command. This will print the version number to the terminal or command prompt, like this:

Alternatively, you can use the sys.version or sys.version_info attributes of the sys module in the Python standard library to print the version information. Here is an example:

This will print something like the following to the output:

The sys.version_info attribute is a named tuple with several attributes that contain detailed information about the version of Python that is installed. You can access these attributes to get more specific information, like the major and minor version numbers, the release level, and the serial number. Here is an example:

This will print something like the following to the output:

I hope this helps! Let me know if you have any other questions.