Python Overview

Table of Contents

Overview

History

Python is a high-level, structured, open-source programming language that can be used for a wide variety of programming tasks. Python was created by Guido Van Rossum in the early 1990s; its following has grown steadily and interest has increased markedly in the last few years or so. It is named after Monty Python's Flying Circus comedy program.

About Python

Python within itself is an interpreted programming language that is automatically compiled into bytecode before execution It is also a dynamically typed language that includes (but does not require one to use) object-oriented features and constructs.The most unusual aspect of Python is that whitespace is significant; instead of block delimiters (braces → "{}" in the C family of languages), indentation is used to indicate where blocks begin and end.

Another great feature of Python is its availability for all platforms. Python can run on Microsoft Windows, Macintosh and all Linux distributions with ease. This makes the programs very portable, as any program written for one platform can easily be used on another.

Python provides a powerful assortment of built-in types (e.g., lists, dictionaries and strings), a number of built-in functions, and a few constructs, mostly statements. For example, loop constructs that can iterate over items in a collection instead of being limited to a simple range of integer values. Python also comes with a powerful standard library, which includes hundreds of modules to provide routines for a wide variety of services including regular expressions and TCP/IP sessions.

Python is used and supported by a large Python Community that exists on the Internet. The mailing lists and news groups like the tutor list actively support and help new python programmers. While they discourage doing homework for you, they are quite helpful and are populated by the authors of many of the Python textbooks currently available on the market.

Python Features

Easy-to-learn : Python is easy to learn and use. It is developer-friendly and high level programming language.
Easy-to-read : Python code is more clearly defined and visible to the eyes.
Easy-to-maintain : Python's source code is fairly easy-to-maintain.
Interactive Mode : Python has support for an interactive mode which allows interactive testing and debugging.
Free and Open Source: Python language is freely available at offical web address.The source-code is also available. Therefore it is open source.
Portable: Python can run on a wide variety of hardware platforms and has the same interface on all platforms.
Extendable: You can add low-level modules to the Python interpreter. These modules enable programmers to add to or customize their tools to be more efficient.
Object-Oriented Language : Python supports object oriented language and concepts of classes and objects come into existence.
Large Standard Library: Python has a large and broad library and prvides rich set of module and functions for rapid application development.
GUI Programming: Python supports GUI applications that can be created and ported to many system calls, libraries and windows systems, such as Windows MFC, Macintosh, and the X Window system of Unix.
Scalable: Python provides a better structure and support for large programs than shell scripting.
Integrated: It can be easily integrated with languages like C, C++, JAVA etc.

Getting started

Python Set up

  • Most operating systems other than Windows already have Python installed by default.
  • To install Python on Windows, go to the python.org[link] download page and download Python. Run the Python installer and accept all the defaults.
  • When Python is installed, you can open Interpreter console and wrote your 1st “Hello World” program.
>>> print("Hello World!")
Hello World!
  • You can use any text editor to write your python program/script. Then save it with .py extension.
  • You can run your python program/script by typing python and the file name with .py extension on your terminal.

Interactive Prompt

  • The interactive prompt runs code and echoes results as you go, but it doesn’t save your code in a file.
  • It turns out to be a great place to both experiment with the language and test program files on the fly.
  • You write code after >>> and press the Enter key to get the output.
>>> print("Hello World!")
Hello World!
>>> 2+6
8

Your First Python Program

Open your favorite text editor (e.g., vi, Notepad, or the IDLE editor),type the following statements into a new text file named script1.py, and save it in yourworking code directory. For linux write (#!/usr/local/bin/python) at the beginning.

print(“Hello User!”)
print(“Welcome to Python Easy!”)
print(2 ** 6)
x = 'Python'
print(x * 3) # String repetition

Running Files with Command Line

Once You have saved the file you can run it with command window. Move to the directory in which you have saved the script. Then type python and then the file name with .py extension to execute the scripts. You will get the following result.

C:\code> python script1.py
Hello User!
64
PythonPythonPython

Indentation

The indentation rule may seem unusual at first glance to programmers accustomed to C-like languages, but it is a deliberate feature of Python, and it’s one of the main ways that Python almost forces programmers to produce uniform, regular, and readability.

if x:
    if y:
        statement1
else:
    statement2

Nested statements are blocked and associated by their physical indentation(without braces).

Click any Link
to navigate to certain page easily
Write a line to us
Your Email
Title
Description