Thursday 9 April 2015

Python

Python (programming language) Part 1

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C++ or Java.
Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive standard library
CPython, the reference implementation of Python, is free and open-source software and has a community-based development model, as do nearly all of its alternative implementations. CPython is managed by the non-profit Python Software Foundation.
Python was conceived in the late 1980s and its implementation was started in December 1989 by Guido van Rossum at CWI in the Netherlands as a successor to the ABC language (itself inspired by SETL) capable of exception handling and interfacing with the Amoeba operating system.
Python 2.0 was released on 16 October 2000, and included many major new features including a full garbage collector and support for Unicode.
Python 3.0 (also called Python 3000 or py3k), a major, backwards-incompatible release, was released on 3 December 2008 after a long period of testing.

Features:-
Python is a multi-paradigm programming language: object oriented programming and structured programming are fully supported, and there are a number of language features which support functional programming and aspect-oriented programming (including by meta programming and by magic methods). 
Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage collector for memory management. An important feature of Python is dynamic name resolution (late binding), which binds method and variable names during program execution.
Syntax and Semantics
Python is intended to be a highly readable language. It is designed to have an uncluttered visual layout, frequently using English keywords where other languages use punctuation. Python uses whitespace indentation, rather than curly braces or keywords, to delimit blocks; this feature is also termed the off-side rule.

Statements and control flow

Python's statements include (among others):
·         The if statement, which conditionally executes a block of code, along with else and else if (a contraction of else-if).
·         The for statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block.
·         The while statement, which executes a block of code as long as its condition is true.
·         The try statement, which allows exceptions raised in its attached code block to be caught and handled by except clauses; it also ensures that clean-up code in a finally block will always be run regardless of how the block exits.
·         The class statement, which executes a block of code and attaches its local namespace to a class, for use in object-oriented programming.
·         The def statement, which defines a function or method.

 

Expressions:-

Python expressions are similar to languages such as C and Java:
·         Addition, subtraction, and multiplication are the same, but the behavior of division differs. Python also added the ** operator for exponentiation.
·         In Python, == compares by value, in contrast to Java, where it compares by reference. (Value comparisons in Java use the equals () method.) Python's is operator may be used to compare object identities (comparison by reference). Comparisons may be chained, for example a <= b <= c.
·         Python uses the words and, or, not for its Boolean operators rather than the symbolic &&, ||, ! Used in Java and C.
·         Python has a type of expression termed a list comprehension. Python 2.4 extended list comprehensions into a more general expression termed a generator expression.
·         Anonymous functions are implemented using lambda expressions; however, these are limited in that the body can only be a single expression.







No comments:

Post a Comment