Check the Python version

Easysys Module Programs · 4 of 20

Write a Python program that checks it is running on Python 3.10 or newer.

Advertisement
Output
3
supported

Approach

  1. Compare sys.version_info with a tuple.

Solution

Python
import sys print(sys.version_info.major)print("supported" if sys.version_info >= (3, 10) else "please upgrade")
Output
3
supported

Learn the concept

New to this topic? Read the lesson, then come back.

More sys module programs

← All 20 sys Module Programs

Leave a Comment