Write below the code and run. It will show the Python version
first import sys
import sys
If you not defined 'sys' then it will show the below error:
NameError: name 'sys' is not defined
Print "Python Version " as a string
print("Python Version")
Print python version. Below the code
print(sys.version)
print "Version Info" as a string.
print("Version Info")
Print System Version Information
print(sys.version_info)
Full code:
import sys
print("Python Version")
print(sys.version)
print("Version Info")
print(sys.version_info)
Know the Python version through the Linux Command:
It will show python version 3
$ python3 --version
It will show python version 2
$ python --version
Know the Python version through the Windows Command:
Go to windows command and type below the code:
c\user\pc> python --version