sending the wrong numbertypeor value of parameters to function is another common cause for an exception for examplea call to abshello will raise typeerror because the parameter is not numericand call to abs( will raise typeerror because one parameter is expected valueerror is typically raised when the correct number and type of parameters are sentbut value is illegitimate for the context of the function for examplethe int constructor accepts stringas with int )but valueerror is raised if that string does not represent an integeras with int or inthello python' sequence types ( listtupleand strraise an indexerror when syntax such as data[kis used with an integer that is not valid index for the given sequence (as described in section sets and dictionaries raise keyerror when an attempt is made to access nonexistent element raising an exception an exception is thrown by executing the raise statementwith an appropriate instance of an exception class as an argument that designates the problem for exampleif function for computing square root is sent negative value as parameterit can raise an exception with the commandraise valueerrorx cannot be negative this syntax raises newly created instance of the valueerror classwith the error message serving as parameter to the constructor if this exception is not caught within the body of the functionthe execution of the function immediately ceases and the exception is propagated to the calling context (and possibly beyondwhen checking the validity of parameters sent to functionit is customary to first verify that parameter is of an appropriate typeand then to verify that it has an appropriate value for examplethe sqrt function in python' math library performs error-checking that might be implemented as followsdef sqrt( )if not isinstance( (intfloat))raise typeerrorx must be numeric elif raise valueerrorx cannot be negative do the real work here checking the type of an object can be performed at run-time using the built-in functionisinstance in simplest formisinstance(objclsreturns true if objectobjis an instance of classclsor any subclass of that type in the above examplea more general form is used with tuple of allowable types indicated with the second parameter after confirming that the parameter is numericthe function enforces an expectation that the number be nonnegativeraising valueerror otherwise