Python Introduction

This python tutorial is trying to cover basic concepts, all the features in Python language and also has some hands on in python programming.
Python is easy to use, and python can be installed on Windows, Mac OS X, and Unix operating systems.

What is python?

Who is developed python?Developed by Guido van Rossum at the National Research Institute for Mathematics and Computer Science in the Netherlands.

Python is a high-level, interpreted, interactive and object-oriented scripting language.

Interpreted - python code is processed at runtime by the interpreter and do not need to compile your program before executing it. Python interpreter can be easily extended with new functions and data types implemented in C or C++ programming languages.

Interactive - python prompt is available to interact with the interpreter directly.

Object-Oriented -python supports Object-Oriented programming.

Highly readable.

Provides the support to write functional and structured programming as well.

Automatic garbage collection.

High-level dynamic data types.

Python advantages

Python is a real programming language, provides more structure and support for large programs.

Python provides more error checking than C.

Python is an interpreted language, so it reduces considerable time during program development because no compilation and linking.

Python supports to write program compactly and readably. Python programs are typically much shorter than equivalent program in C, C++, or Java beacuase

high-level data types help to write complex operations in a single line.

no beginning and ending brackets, statements are grouped using indentation.

variable or argument declarations are not available.

Python is extensible because new built in functions or module can be added in python interpreter if you know how to write C program.

Python installation

Python interpreter

Python interpreter is written in C program which directly executes or performs python scripts.

Python interpreter is usually installed under /usr/local/bin/python.

Python interpreter can be invoked using command

python

Arguments can be passed to python program. After python scripts name, remaining arguments are converted as list of strings and assigned to variable argv and it is available in sys module. This argv variable can be accessed in python program

To exit the python interactive mode: type exit() or quit() or press ctrl+D

>>>exit()
or
>>>quit()

Source Code Encoding - Python scripts files are encoded in UTF-8 format default.
A special comment line should be added in first line of python scritps to declare an encoding other than the default format.

# -*- coding: encoding -*-

if source code starts with a UNIX “shebang” line, then encoding comment should be in second line.