Write a Python Program to get Python Version you are using
Write a python program to get the python version you are using is provided on this page.
Write A Python Program To Get The Python Version You Are Using
There are couple of ways to get python version. All will be provided below.
Program 1
First way is to use the sys module and access the 'version' variable.
There is also 'version_info' which provides more info on python version.
import sys
print("Python version : ")
print(sys.version)
Program 2
Second way is using platform module.
platform module has python_version() method which only returns the version number.
import platform
print(platform.python_version())
Output
3.10.4
You will receive different number depending on your version.
Program 3
Next is using same platform module but different method python_version_tuple() which returns a tuple containing numbers after every decimal.
import platform
print(platform.python_version_tuple())
Comments