Logical Function In Python Definition Range