Home » Python » Python programs

Python program to print the version information

Here, we are going to learn how to print the version information in Python programming language?
Submitted by IncludeHelp, on March 23, 2020

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: major, minor, micro, releaselevel, and serial.

Note: "sys.version" is used to get the Python version only.

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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.