Posts

Namespace and scopes in python

Image
  Namespaces A Namespace Python is a mapping between  variable   names  and  objects . There are 3  general   kinds  of namespaces , main, and builtins namespaces — All the  erected  in  names   live   then  and this namespace is created when the  practitioner  starts up. Global  namespace — All  names   declared  with the  global  keyword  live   then . Original  namespace — The  original  variables  declared  within a module or a  function   belong   then . Compass A  Compass  is a textual  area  of a Python  program  where a Namespace is  directly   accessible . Any  direct   reference  to a  name  with in a  compass  is  directly   looked  up in the namespace the  compass  has  access  to. Name   hunt When a python  law  executes, a  hunt  for a  name  happens in this  order .  Original  —  Hunt  for the  name  in the  original  namespace of the  function Enclosing  — If it’s not  present  in the  original  namespace,  hunt  for it in the  compass  of the  enclosing   function . 

Boolean Operators in Python

Image
  Boolean  Expression(Operator)  in Python Boolean  Expression  helps in  attesting   True  OR False  given  a comparison. Illustration > 4 == 4 True > 6 == 2 False True &  False aren't  strings . They  belong  to  type  bool. We can  validate  the  type  by  using  the  following   illustration   law .>  type  (  True ) type 'bool' >  type ( False) type 'bool' Comparison  Drivers  in Python Comparison  Drivers  are  available  for the  purpose  of comparison. We  validate   equal  to,  lesser  than or  lower  than and  so   on . To  support  these  kind  of comparisons, we  use  comparison  drivers . For  illustration , the  before   used ' == 'is one  zilches  the comparison  driver . The  following  are list of comparison  drivers a == b# it represents a  equal  to b a> b# it represents a  lesser  than b a< b# it represents a  lower  than b a! = b# it represents a not  equal  to b a> = b# it represents a  lesser  than or  equal  t