p

python tutorial - Python with Keyword | Python Keywords - learn python - python programming



  • Keywords are special reserved words which convey a special meaning to the compiler/interpreter.
 python keywords
  • Each keyword have a special meaning and a specific operation.
  • Keywords are the reserved words in Python.
  • We cannot use a keyword as variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language.
  • In Python, keywords are case sensitive.
  • There are 33 keywords in Python 3.3. This number can vary slightly in course of time.
  • All the keywords except True, False and None are in lowercase and they must be written as it is. The list of all the keywords are given below.
  • The following is a list of keywords for the Python programming language. and del from not while as elif global or with assert else if pass yield break except import print class exec in raise continue finally is return def for lambda try.
  • Python is a dynamic language. It changes during time.
  • Here are simple rules to define a function in Python. Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).
  • Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.

Keywords Explained:

print print to console
while controlling the flow of the program
for iterate over items of a collection in order that they appear
break interrupt the (loop) cycle, if needed
if used to determine, which statements are going to be executed.
continue used to interrupt the current cycle, without jumping out of the whole cycle.
New cycle will begin.
elif stands for else if.If the first test evaluates to False,then it continues with the next one
else is optional. The statement after the else keyword is executed,
unless the condition is True
is tests for object identity
not negates a boolean value
and all conditions in a boolean expression must be met
or at least one condition must be met.
import import other modules into a Python script
as if we want to give a module a different alias
from for importing a specific variable, class or a function from a module
def used to create a new user defined function
return exits the function and returns a value
lambda creates a new anonymous function
global access variables defined outside functions
try specifies exception handlers
except catches the exception and executes codes
finally is always executed in the end. Used to clean up resources.
raise create a user defined exception
del deletes objects
pass does nothing
assert used for debugging purposes
class used to create new user defined objects
exec executes Python code dynamically
yield is used with generators.

Related Searches to Python Keywords