Q:

Python program to print the version information

belongs to collection: Python basic programs

0

To print the version information, we use "sys.version_info", which can be used after importing the "sys" module, it returns a tuple containing some components of the version number: majorminormicroreleaselevel, and serial.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

In the below code, we are implementing a Python program to print version information.

# Python program to print the version information

# importing the module
import sys

# printing version info
print("Python version: ", sys.version)
print("Python version info: ", sys.version_info)

print("Python version info[0]: ", sys.version_info[0])
print("Python version info[1]: ", sys.version_info[1])
print("Python version info[2]: ", sys.version_info[2])
print("Python version info[3]: ", sys.version_info[3])
print("Python version info[4]: ", sys.version_info[4])

Output

ython version:  3.8.1 (default, Feb  2 2020, 08:37:37) 
[GCC 8.3.0]
Python version info:  sys.version_info(major=3, minor=8, micro=1, releaselevel='final', serial=0)
Python version info[0]:  3
Python version info[1]:  8
Python version info[2]:  1
Python version info[3]:  final
Python version info[4]:  0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python program to find sum of all digits of a numb... >>
<< Python program to print the list of all keywords...