Getting Maya version - it might be confusing, the return value is unicode (sort of string). So for comparing version, it's ideal to convert to INT first.
import maya.cmds as mc
mayaVersion = int( mc.about(v=True) )
if mayaVersion > 2020:
dosomething()