Information of python
python
Python is an interpreted high-level and general
purpose programing language. Python's design philosophy emphasizes code-readability
with its notable use of significant indentation.
Its language constructs and object-oriented approach aim to
help programmers write clear, logical code for small and large-scale
projects.
Python is dynamically-typed and garbage-collected.
It supports multiple programming paradigms, including structured (particularly,
procedural),object-oriented and function programming. Python is often
described as a "batteries included" language due to its
comprehensive standard library.
Guido van Rossum began
working on Python in the late 1980s, as a successor to the ABC programming
language, and first released it in 1991 as Python 0.9.0. Python 2.0 was
released in 2000 and introduced new features, such as list comparisons and
a garbage collection system using reference counting and was discontinued
with version 2.7.18 in 2020. Python 3.0 was released in 2008 and was a
major revision of the language that is not completely backward-compatible and
much Python 2 code does not run unmodified on Python 3.
Python consistently ranks as
one of the most popular programming languages.
Features:
Python strives for a neater, less-cluttered syntax and synchronic linguistics whereas giving developers a variety in their secret writing methodology. In distinction to Perl's "there is over a method to undertake to to it" expression, Python embraces a "there need to be one and ideally only 1 obvious because of do it" vogue philosophy. Alex Martelli, a Fellow at the Python package Foundation and Python book author, writes that "To describe one factor as 'clever' is not thought of a compliment among the Python culture."
Python's developers plan to avoid premature improvement, and reject patches to non-critical parts of the cPython reference implementation which may offer marginal can increase in speed at the worth of clarity. Once speed is significant, a Python applied scientist can move time-critical functions to extension modules written in languages like C, or use PyPy, a just-in-time compiler. Python is in addition out there, that interprets a Python script into C and makes direct C-level API calls into the Python interpreter.
An important goal of Python's developers is keeping it fun to use. this could be reflected among the language's name a tribute to nation comedy cluster Monty Python and in usually elfin approaches to tutorials and reference materials, like examples that talk over with spam and eggs (from an illustrious Monty Python sketch) instead of the standard foo and bar.
A common neologism among the Python community is pythonic, which can have an oversized vary of meanings related to program vogue. to say that code is pythonic is to say that it uses Python idioms well, that it's natural or shows fluency among the language, that it conforms with Python's minimalist philosophy and stress on readability. In distinction, code that is hard to grasp or reads style of a rough transcription from another programming language is termed unpythonic.
Users and admirers of Python,
notably those thought of knowledgeable or absolutely fledged, unit of measurement
generally expressed as Pythonistas
Statements:
★The assignment statement, employing a single sign =.
★The if statement, that not absolutely executes a block of
code, alongside else and elif (a contraction of else-if).
★The for statement, that iterates over AN iterable object,
capturing every part to a neighborhood variable to be used by the connected
block.
★The whereas statement, that executes a block of code as long
as its condition is true.
★The strive statement, that permits exceptions raised in its
connected code block to be caught and handled by except clauses; it conjointly
ensures that clean-up code during a finally block can perpetually be run
despite however the block exits.
★The raise statement, wont to raise a fixed exception or
re-raise a caught exception.
★The class statement, that executes a block of code and
attaches its native namespace to a category, to be used in object-oriented
programming.
★The def statement, that defines a perform or technique.
★The with statement, from Python a pair of.5 discharged in
Sep 2006,[81] that encloses a code block at intervals a context manager (for
example, getting a lock before the block of code is run and emotional the lock
later on, or gap a file and so closing it), permitting
resource-acquisition-is-initialization (RAII)-like behavior and replaces a
typical try/finally idiom.[82]
★The break statement, exits from a loop.
★The continue statement, skips this iteration and continues
with subsequent item.
★The Del statement, removes a variable, which implies the
reference from the name to the worth is deleted and making an attempt to use
that variable can cause a slip-up. A deleted variable will be reassigned.
★The pass statement that is a NOP. It’s syntactically
required to make AN empty code block.
★The assert statement, used throughout debugging to visualize
for conditions that ought to apply.
★The yield statement, that returns a price from a generator
perform. From Python a pair of.5, yield is additionally AN operator. this kind
is employed to implement coroutines.
★The comeback statement, wont to come back a price from a
perform.
★The import statement, that is employed to import modules
whose functions or variables will be utilized in this program. There ar 3 ways
of victimization import: import [as ] or
from import * or from import
[as ], [as ]
★The assignment statement (=) operates by binding a
reputation as a relation to a separate, dynamically-allocated object. Variables
is also after rebound at any time to any object. In Python, a variable name may
be a generic reference holder and does not have a set knowledge sort related to
it. but at a given time, a variable can confer with some object, which can have
a sort. this is often observed as dynamic writing and is contrasted with
statically-typed programming languages, wherever every variable could solely
contain values of an exact sort.
★Python doesn't support tail decision improvement or superior
continuations, and, in line with Guido van Rossum, it ne'er can.[83][84] but,
higher support for coroutine-like practicality is provided in a pair of.5, by
extending Python's generators.[85] Before a pair of.5, generators were lazy
iterators; data was passed unidirectionally out of the generator. From Python a
pair of.5, it's potential to pass data into a generator perform, and from
Python three.3, the data will be knowledgeable multiple stack levels.
Expressions:
★Some Python expressions area unit the same as those found in languages like C and Java, whereas some area unit not:
★Addition, subtraction, and multiplication area unit
constant, however the behavior of division differs. There are a unit 2 forms of
divisions in Python. they're floor division (or whole number division) // and
floating-point/division. Python conjointly uses the ** operator for
operation.
★From Python three.5, the new @ infix operator was
introduced. it's meant to be utilized by libraries like NumPy for matrix
operation.
★From Python three.8, the syntax :=, known as the 'walrus
operator' was introduced. It assigns values to variables as a part of a bigger
expression.
★In Python, == compares by price, versus Java, that compares
numeric by value and objects by reference. (Value comparisons in Java
on objects is performed with the equals() technique.) Python's is operator is
also wont to compare object identities (comparison by reference). In Python,
comparisons is also bound, for instance a <= b <= c.
★Python uses the words and, or, not for its Boolean operators
instead of the symbolic &&, ||, ! employed in Java and C.
★Python incorporates a sort of expression termed a listing
comprehension further as a a lot of general expression termed a generator
expression.
★Anonymous functions area unit enforced mistreatment lambda
expressions; but, these area unit restricted in this the body will solely be
one expression.
★Conditional expressions in Python area unit written as x if
c else y(different so as of operands from the c ? x : y operator common to
several different languages).
★Python makes a distinction between lists and tuples. Lists
area unit written as [1, 2, 3], area unit changeable, and can't be used because
the keys of dictionaries (dictionary keys should be immutable in Python). Tuples area unit written as (1,
2, 3), area unit immutable and therefore
is used because the keys of dictionaries, provided all components of the tuple
area unit immutable . The + operator is wont to concatenate 2 tuples, that
doesn't directly modify their contents, however rather produces a replacement
tuple containing the weather of each provided tuples. Thus, given the variable
t ab initio adequate to (1, 2, 3), death penalty t = t + (4, 5) initial
evaluates t + (4, 5), that yields (1, 2, 3, 4, 5), that is then appointed back
to t, thereby effectively "modifying the contents" of t, whereas
orthodox to the immutable nature of tuple
objects. Parentheses area unit nonobligatory for tuples in unambiguous
contexts.