Python

What is Python ?
Python is a simple, easy to learn, powerful, high level and object-oriented programming language.

History of python ?
  • The implementation of Python was started in the December 1989 by Guido Van Rossum at CWI in Netherlands.
  • ABC programming language is said to be the predecessor of Python language which was capable of Exception Handling and interfacing with Amoeba Operating System.

Features of python :
  • Easy to Learn and Use
  • Expressive
  • Interpreted 
  • Cross-platform
  • Free and Open Source
  • Object-Oriented Language
  • Extensible
  • Large Standard Library
  • GUI Programming Support
  • Integrated

Pro's of Python :
  • Python is easy to learn.
  • Supports multiple systems and platforms.
  • Object Oriented Programming-driven.
  • Gives rise to quick development by using less code. Even a small team can handle Python effectively.
  • Allows to scale even the most complex applications with ease.
  • A large number of resources are available for Python.

Con's of Python :
  • Python is slow.
  • It is not a very good language for mobile development.
  • It is not a good choice for memory intensive tasks.
  • Has limitations with database access.
  • Python is not good for multi-processor/multi-core work.

Setup & Installation :
  • Go to the official website of python and click on download.
            

  • Double click on the downloaded file and click on default installation or customized installation.
  • Choose the features and click on next.
  • Choose the installation location and press install.
  • Click on close after setup was completed.
  • Program to print hello Python.
             

Basic concepts in Python : 
Variable :
  • Variable is a name which is used to refer memory location. Variable also known as identifier and used to hold value.
  • Python does not bound us to declare variable before using in the application. It allows us to create variable at required time.
  • We don't need to declare explicitly variable in Python. When we assign any value to the variable that variable is declared automatically.
  • Python allows us to assign a value to multiple variables in a single statement which is also known as multiple assignment.
         

String :
  • string is a built-in type text sequence. It is used to handle textual data in python.
  • We can simply create Python String by enclosing a text in single as well as double quotes. Python treat both single and double quotes statements same.
  • Both forward as well as backward indexing are provided using Strings in Python. Forward indexing starts with 0,1,2,3,....Backward indexing starts with -1,-2,-3,-4,....
  • Program to string concatenation.
                   

  • Program to find sub string and occurrence of a sub string in main string.
               

List : 
  • List is a data structure which is used to store various types of data.
  • Lists are mutable i.e., Python will not create a new list if we modify an element of the list.
  • It works as a container that holds other objects in a given order. We can perform various operations like insertion and deletion on list.
  • A list can be composed by storing a sequence of different type of values separated by commas.
  • Python list is enclosed between square([]) brackets and elements are stored in the index basis with starting index 0.


  • Program to ask users name and his age and then write sentence.


Exception Handling : 
  • Exception can be said to be any abnormal condition in a program resulting to the disruption in the flow of the program.
  • The malicious code (code having exception) is enclosed in the try block.
  • Try block is followed by except statement. There can be multiple except statement with a single try block.
  • Except statement specifies the exception which occurred. In case that exception is occurred, the corresponding statement will be executed.
  • At the last we can provide else statement. It is executed when no exception is occurred.
  • Finally block will always be executed irrespective of the exception.
  • We can explicitly throw an exception in Python using ?raise? statement. raise will cause an exception to occur and thus execution control will stop in case it is not handled.