Monday, July 4, 2016

Python Keywords


Keywords :
It is a special reserve words which have a special meaning for                                                                 Interpreter/compiler.
Each keywords have a specific operations and a special meaning.

Let's Know about python Keywords 


List of keywords used in python are:


  • True : True and False are truth values in Python. They are the results of comparison operations or logical (Boolean) operations in Python.
  • False : True and False are truth values in Python. They are the results of comparison operations or logical (Boolean) operations in Python.
  • None : None is a special constant in Python that represents the absence of a value or a null      value. It is an object of its own datatype, the NoneType.
  • and : and is the logical operator in Python. and will result into True only if both the operands are True.
  • as : as is used to create an alias while importing a module. It means giving a different name     (user-defined) to a module while importing it.
  • asset : assert is used for debugging purposes. While programming, sometimes we wish to know the internal state or check if our assumptions are true. assert helps us do this and find  bugs more conveniently. assert is followed by a condition. If the condition is true, nothing happens. But if the condition is false, AssertionError is raised. 
  • def : def is used to define a user-defined function.
  • class : class is used to define a new user-defined class in Python.
  • continue : continue are used inside for and while loops to alter their normal behavior. continue  causes to end the current iteration of the loop, but not the whole loop.
  • break : break is used inside for and while loops to alter their normal behavior. break will end   the smallest loop it is in and control flows to the statement immediately below the loop.
  • if : if is used for conditional branching or decision making.
  • else : else is used for conditional branching or decision making.
  • elif : elif is used for conditional branching or decision making.
  • finally : finally is used with try…except block to close up resources or file streams. Using        finally ensures that the block of code inside it gets executed even if there is an unhandled exception.
  • del : del is used to delete the reference to an object. Everything is object in Python. We can   delete a variable reference using del.
  • except : except is used with exceptions in Python. Exceptions are basically errors that suggests something went wrong while executing our program.    
  • global : global is used to declare that a variable inside the function is global (outside the function).
  • for : for is used for looping. Generally we use for when we know the number of times we want to loop. In Python we can use it with any type of sequence like a list or a string. 
  • from : from…import is used to import specific attributes or functions into the current namespace.
  • import : import keyword is used to import modules into the current namespace. 
  • raise : raise is used with exceptions in Python.We can raise an exception explicitly with the raise keyword. 
  • try : try is used with exceptions in Python.
  • or : or is the logical operator in Python. and will result into True only if both the operands are True.
  • return : return statement is used inside a function to exit it and return a value. If we do not return a value explicitly, None is returned automatically.
  • pass : pass is a null statement in Python. Nothing happens when it is executed. It is used as a placeholder.
  • nonlocal : The use of nonlocal keyword is very much similar to the global keyword.  it is used to declare that a variable inside a nested function (function inside a function) is not local to it, meaning it lies in the outer inclosing function.
  • in : in is used to test if a sequence (list, tuple, string etc.) contains a value. It returns True if the value is present, else it returns False.
  • not : not is the logical operator in Python. and will result into True only if both the operands are True.
  • is : is is used in Python for testing object identity.is is used to test if the two variables refer to the same object. It returns True if the objects are identical and False if not.
  • lambda : lambda is used to create an anonymous function (function with no name). It is an inline function that does not contain a return statement.It consists of an expression that is evaluated and returned. 





No comments:

Post a Comment