16. try : this keyword is used to handle exceptions, is used to catch errors in the code, except for the keyword. The code in the try block is checked if there is any type of error other than the block being executed.
17. Except : As explained above, this works in conjunction with "trying" to catch exceptions.
18. promotion : Also used for exception handling to explicitly raise exceptions.
19. finally : no matter what is the result of the "try" block, the block called "finally" is always executed. Detailed article — Python Exception Handling
20. for : This keyword is used for flow control and for loops.
21. while : Works similar to “for”, used for flow control and for loops.
22. pass : This is a null statement in python. Nothing happens when it is encountered. This is used to prevent indentation errors and is used as a placeholder
Detailed article — imports, from and how
26. lambda : This keyword is used to create inline return functions without internal instructions. Detailed article — map, filter, lambda
27. return : This keyword is used to return from a function. Detailed article — yield keyword
29. with : This keyword is used to wrap the execution of a block of code in methods defined by the context manager. This keyword has little use in everyday programming.
30. in : This keyword is used to check if the container contains a value. This keyword is also used to traverse the container.
31. is : This keyword is used to check the identity of an object, that is, to check if both objects occupy the same memory space or not.
|
Output:
s is part of pythonengineering pythonengineering True False
32. global : This keyword is used to define a variable within a function that has global scope.
33. non-local : This keyword works similarly to the global one, but instead of the global one, this keyword declares a variable pointing to the variable of the outer enclosing function, in the case of nested functions.
|
Output:
10 5 5 Value of a using nonlocal is: 10 Value of a without using nonlocal is : 5
This article courtesy of Manjeet Singh (S. Nandini) . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.