In some cases, we can reduce an if ... else statement down to a single conditional expression. The syntax for a conditional expression is:
expression1 if boolean_expression else expression2Figure 4.1 Some of Python’s exception hierarchy
Figure 4.2 Try ... except ... finally control flows
class exceptionName (baseException): passWhat stands out here is the use of the global statement. This statement is used to tell Python that a variable exists at the global (file) scope, and that assignments to the variable should be applied to the global variable, rather than cause a local variable of the same name to be created.
If we did not use the global statement the program would run, but when Python encountered the Language variable in the if statement it would look for it in the local (function) scope, and not finding it would create a new local variable called Language, leaving the global Language unchanged.
lambda parameters: expression
elements.sort(key=lambda e: (e[1], e[2]))
elements.sort(key=lambda e: e[1:3])
elements.sort(key=lambda e: (e[2].lower(), e[1]))assert boolean_expression, optional_expression










