1.INTRODUCTION TO PYTHON

What is PYTHON?

  • Python is a widely used general-purpose high level  popular programming language. It was created in 1991 by Guido van Rossum  and developed by Python Software Foundation.
  • Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to compile your program before executing it. This is similar to PERL and PHP.
  • Python is Interactive − You can actually sit at a Python prompt and interact with the interpreter directly to write your programs.
  • Python is Object-Oriented − Python supports Object-Oriented style or technique of programming that encapsulates code within objects.
  • Python is a Beginner's Language − Python is a great language for the beginner-level programmers and supports the development of a wide range of applications from simple text processing to WWW browsers to games.

Feature of Python:

  • Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax. This allows the student to pick up the language quickly.
  • 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.
  • A broad standard library − Python's bulk of the library is very portable and cross-platform compatible on UNIX, Windows, and Macintosh.
  • Interactive Mode − Python has support for an interactive mode which allows interactive testing and debugging of snippets of code.
  • 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.
  • Databases − Python provides interfaces to all major commercial databases.
  • 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.

Python is used for:

  • 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-orientated way or a functional way.

There are two major Python versions- Python 2 and Python 3. Both are quite different

A LITTLE HISTORY OF PYTHON 2 VS 3:

  • Python 2.0 was first released in 2000. Its latest version, 2.7, was released in 2010.
  • Python 3.0 was released in 2008. Its newest version, 3.6, was released in 2016, and version 3.7 is currently in development.
  • Although Python 2.7 is still widely used, Python 3 adoption is growing quickly. In 2016, 71.9% of projects used Python 2.7, but by 2017, it had fallen to 63.7%. This signals that the programming community is turning to Python 3–albeit gradually–when developing real-world applications.
  • Notably, on January 1, 2018, Python 2.7 will “retire” and no longer be maintained. (The clock is literally ticking!).

5 Main Differences between Python 2 and Python 3 2018:

 

Python Syntax compared to other programming languages:

  • Python was designed to 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.

Beginning with Python programming:1) Finding an Interpreter:

Before we start Python programming, we need to have an interpreter to interpret and run our programs. 
Windows:There are many interpreters available freely to run Python scripts like IDLE ( Integrated Development Environment ) which is installed when you install the python software from http://python.org/
Linux:For Linux, Python comes bundled with the linux.
2) Writing first program:
Following is first program in Python
#script Begins
Print("This is our First Python Program")
#Script Ends
OUTPUT: This is our First Python Program
Let us analyze the script line by line.
Line 1 : [# Script Begins]  In Python comments begin with #. So this statement is for readability of code and ignored by Python interpreter.
Line 2 : [print(“This is our First Python Program”)] In a Python script to print something on the console print() function is used – it simply prints out a line ( and also includes a newline unlike in C ). One difference between Python 2 and Python 3 is the print statement. In Python 2, the “print” statement is not a function, and therefore can be invoked without a parenthesis. However, in Python 3, it is a function, and must be invoked with parentheses.
Line 3 : [# Script Ends] This is just another comment like Line 1.

No comments:

Post a Comment