What is Python?
Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
![]() |
Guido van Rossum. |
It is used for:
web development (server-side),
software development,
mathematics,
system scripting.
What can Python do?
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
Python can be used for rapid prototyping, or for production-ready software development.
Why Python?
Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programs with fewer lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
Python can be treated in a procedural way, an object-oriented way or a functional way.
Good to know
The most recent major version of Python is Python 3, which we shall be using in this tutorial. However, Python 2, although not being updated with anything other than security updates, is still quite popular.
In this tutorial Python will be written in a text editor. It is possible to write Python in an Integrated Development Environment, such as Thonny, Pycharm, Netbeans or Eclipse which are particularly useful when managing larger collections of Python files.
Python Syntax compared to other programming languages
Python was designed for readability, and has some similarities to the English language with influence from mathematics.
Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses.
Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.
Syntax and semantics
Python is meant to be an easily readable language. Its formatting is visually uncluttered and often uses
English keywords where other languages use punctuation. Unlike many other languages, it does not use curly
brackets to delimit blocks, and semicolons after statements are allowed but rarely used. It has fewer
syntactic exceptions and special cases than C or Pascal.
Python's statements include:
The assignment statement, using a single equals sign =
The if statement, which conditionally executes a block of code, along with else and elif (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 (or new syntax except* in Python for exception groups
it also ensures that clean-up code in a finally block is always run regardless of how the block
exits
The raise statement, used to raise a specified exception or re-raise a caught exception
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
The with statement, which encloses a code block within a context manager (for example, acquiring a
lock before it is run, then releasing the lock; or opening and closing a file), allowing resource-
acquisition-is-initialization (RAII)-like behavior and replacing a common try/finally idiom
The break statement, which exits a loop
The continue statement, which skips the rest of the current iteration and continues with the next
The del statement, which removes a variable—deleting the reference from the name to the value,
and producing an error if the variable is referred to before it is redefined
The pass statement, serving as a NOP, syntactically needed to create an empty code block
The assert statement, used in debugging to check for conditions that should apply
The yield statement, which returns a value from a generator function (and also an operator); used
to implement coroutines
The return statement, used to return a value from a function
The import and from statements, used to import modules whose functions or variables can be
used in the current program
The assignment statement ( = ) binds a name as a reference to a separate, dynamically allocated object.
Variables may subsequently be rebound at any time to any object. In Python, a variable name is a generic
reference holder without a fixed data type; however, it always refers to some object with a type. This is
called dynamic typing—in contrast to statically-typed languages, where each variable may contain only a
value of a certain type.
Python does not support tail call optimization or first-class continuations, and, according to Van Rossum,
it never will.
However, better support for coroutine-like functionality is provided by extending
Python's generators.
Before generators were lazy iterators; data was passed unidirectionally out
of the generator. From Python on, it is possible to pass data back into a generator function; and from
version it can be passed through multiple stack levels.
... Easy example.. :-
My contact
Very great information
ReplyDeleteVery good
ReplyDeleteVery good broπ
ReplyDeleteWell done
ReplyDeleteGood bro
ReplyDeleteVery good blog bro...
ReplyDeleteVery helpfull for python beginners
ReplyDeleteSupper & nice
ReplyDeleteVery good bro & very useful
ReplyDelete