首页 > 解决方案 > I want to calculate are of parallelogram only if vertices lie between 0 to 1000 ,i.e. 0<=x<1000. How can I define constraints?

问题描述

How can I define constraints in python? I want to calculate are of parallelogram only if vertices lie between 0 to 1000 ,i.e. 0<=x<1000.

标签: pythondata-science

解决方案


For me, the best method is to throw an exception inside your function. For example :

def yourFunction(x):
    if(0<=x<1000):
        raise SyntaxError("Please provide a correct value")
    pass # your code here

推荐阅读