num num num averagenum +num +num / print ('the average of the three numbers is:',averageoutputthe average of the three numbers is this example gives you an idea of how program may not give you an error but yet logically be incorrect syntax errors exceptions syntaxerror occurs when you try to run syntactically invalid python codethat iswhen you're asking python to execute code that is not actually python code when this happensthe code is not executed at allnot even those lines that are syntactically valid this is very different from an exceptionan exception occurs when there is an error during execution of syntactically valid python code in python terminologyan exception is raised to illustrate thislet' define an unsafe functionthat isa function that can easily result in an exception def oneover( )print /icalling oneover( results in zerodivisionerror ( special kind of exceptionbecause dividing any number by is not allowedexampledef oneover( )print /ioneover( outputzerodivisionerrordivision by zero exception handling an exception can be handled by an enclosing try statement try statement consists of multiple clausesthe first begins with try and the rest begin with excepttry statement with an except clause the try and except block in python is used to catch and handle exceptions python executes code following the try statement as "normalpart of the program the page