Python is a high-level programming language that can be applied in a wide range of modern software development fields. It is described as a general-purpose language because it is used in developing software in a wide range of programming domains.
The inventor of python envisioned a small language but which would be highly extensible by it's users. There is almost a library for anything you will need to do in python, so think about this before re-inventing the wheel.
As of writing of this article python is one of the most widely used programming languages. Tech giants such as YouTube, Google search engine and NASA uses python extensively in their various systems .
Who invented python ?
Python was first released in the early 1990's, it's original founder is a dutch programmer known as Guido van Rossum . He was titled "Python's benevolent dictator for life" for his dedication at making it the success it is today.
Guido van Rossum started python as a hobby project and named his newly invented language after his favorite tv show, a British tv program named Monty Python's Flying Circus . So python language has nothing to do with the reptiles except sharing a common name.
compiled or interpreted ?
Python is regarded as an interpreted language, it comes bundled with an interpreter which translates source code to bytecode and then runs the bytecode statement by statement. In reality python is both compiled and interpreted, but the compilation part is hidden from the user.
In compiled languages , the source code is translated to machine code and saved to a file known as an executable. One can then run the program by running the executable file. If one needs to make a change in their program, they will have to recompile the source code to generate a new executable reflecting the changes done. On the other hand in an interpreted language like python the compilation part is mostly done under the hood. Compilation and execution happens simultaneously hence any modifications in the source code will be reflected without the user having to recompile the source code themselves.
Python's rebellious nature
In the world of computer programming, python is known to go against the norm. Most of features available in most programming languages are usually inherited from a mother language such as C . The reason why python doesn't inherit some features of the C language is because it is made with a readability goal in mind and also to make it's syntax look more like statements in natural languages.
Let us look at the various features which python does differently from other programming languages.
Statement termination
Using a semi-colon to indicate end of a statement is a common and mandatory practice in most programming languages. It even forms one of the most solid programming jokes about how a program can crash making the programmer to spend huge amount of time debugging only to realize that a single missing semi-colon is the cause of all the errors. Well , such jokes are irrelevant to python programming because semi-colons aren't mandatory and rarely do python programmers use them. If you use a semi-colon at the end of a statement, python will not raise any error, it will just ignore it and continue to the next statement. It is considered a good practice in python programming to ignore the semicolon .
Python uses the end of line character ( \n ) to indicate the end of a statement. Programmers do not need to add the line termination character themselves as it is done by text editors.
Indicating blocks
It is a common practice in programming languages to indicate block with curly braces . A right curly brace ( { ) is used to indicate the start of a block and the left-facing one ( } ) the end of a block.
For example a conditional block in C-like languages looks like.
if ( condition ){
...
statement;
statement;
statement;
...
} else if ( condition ){
...
statement;
statement;
statement;
...
} else {
...
statement;
statement;
statement;
...
}
Indentation in such languages is optional and mostly for code clarity
Python famously uses a full colon followed by indentation to indicate blocks.
A python conditional block looks like:
if condition:
...
statement
statement
statement
...
elif condition :
...
statement
statement
statement
...
else:
...
statement
statement
statement
...
The indentation in a python block is not only a must, but the amount of indentation must be uniform across the block for all statements at the same depth as well. This feature forces programmers to write codes which are readable .
Structure of a block
for (some conditions ){
do something;
}
The point here is that the parentheses at the head of the loop are a must. Other blocks including while, if, else if and else follows the same suit.
In python the parentheses at the head of blocks such as an if block are not a must , they are mostly used when the expression in the condition gets complex
it is legal to use python's blocks without parentheses like below
if val1 > val2:
do something