Sunday, 8 September 2013

Dynamic Programming Languages - Python















































Python is a remarkably powerful dynamic and very expressive programming language that is used in a wide variety of application domains. Python is often compared to Tcl, Perl, Ruby, Scheme or Java. that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.


Some of its key distinguishing features include:
  • very clear, readable syntax
  • strong introspection capabilities
  • intuitive object orientation
  • natural expression of procedural code
  • full modularity, supporting hierarchical packages
  • exception-based error handling
  • very high level dynamic data types
  • extensive standard libraries and third party modules for virtually every task
  • extensions and modules easily written in C, C++ (or Java for Jython, or .NET languages for IronPython)
  • embeddable within applications as a scripting interface



Python is Strongly Typed:

A strongly-typed programming language is one in which each type of data (such as integer, character, hexadecimal, packed decimal, and so forth) is predefined as part of the programming language and all constants or variables defined for a given program must be described with one of the data types. Certain operations may be allowable only with certain data types. The language compiler enforces the data typing and use compliance. An advantage of strong data typing is that it imposes a rigorous set of rules on a programmer and thus guarantees a certain consistency of results


Python is Dynamic Language:


Dynamic programming language is a term used broadly in computer science to describe a class of high-level programming languages that, at runtime, execute many common behaviors that other languages might perform during compilation. These behaviors could include extension of the program, by adding new code, by extending objects and definitions, or by modifying the type system, all during program execution. These behaviors can be emulated in nearly any language of sufficient complexity, but dynamic languages provide direct tools to make use of them.










Demo of Python:
































































To view Python rules and regulation

















































































The Read -Eval-Print-Loop or REPL


























To Exit from Python 







Significantly 4 white spaces are needed for python programming

























































To get to know about specific python modules, we could use below help command
















To get to know about specific python functions in modules, we could use below help command









Press Q to return to REPL








We can create alias for particular function of module as below


















INTEGER Operation











Floating Point Operations


























































































































































Strings and Collections






































































































String in the python is sequence type and collection type

















































































BYTES Data type is used in python for below purpose



















































































Modularity







































Creating, Running and Importing a module



First type some python code in text file(words.py) and store it under "pyfund" directory under your home directory with *.py extension.




And move in that directory by giving below command to load modules into Python









Import the module code into our Python environment







Defining functions and returning values













 

Difference between Module Import and Execution
 

Importing Modules





 






































































































Objects in Python



Below sequence of steps are happening while creating immutable INT variables in python












































































Object Creation methodology in Python programming

























Mutable LIST Object operation in Python programming





















































Passing Parameters in Function in Python







































































Python Type system

































Variable Scoping






































































































Classes



























































































































Handling exceptions













































Call stack of this exception









































































































































































































































































































































































No comments:

Post a Comment