Introduction to Python

Python Introduction

  • Python is a general purpose, dynamic, high level, and interpreted programming language. 
  • It supports Object Oriented programming approach to develop applications. It is simple and easy to learn and provides lots of high-level data structures.
  • The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python Web site, https://www.python.org/, and may be freely distributed. 
  • The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional documentation.
  • The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). 
  • Python is also suitable as an extension language for customizable applications.
  • Python is easy to learn yet powerful and versatile scripting language, which makes it attractive for Application Development.
  • Python's syntax and dynamic typing with its interpreted nature make it an ideal language for scripting and rapid application development.
  • Python supports multiple programming pattern, including object-oriented, imperative, and functional or procedural programming styles.
  • Python is not intended to work in a particular area, such as web programming. That is why it is known as multipurpose programming language because it can be used with web, enterprise, 3D CAD, etc.
  • We don't need to use data types to declare variable because it is dynamically typed so we can write a=10 to assign an integer value in an integer variable.
  • Python makes the development and debugging fast because there is no compilation step included in Python development, and edit-test-debug cycle is very fast.

Python 2 vs. Python 3


It is used for:

  1. web development (server-side),
  2. software development,
  3. mathematics,
  4. system scripting.
What can Python do?
  • 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.
  • In most of the programming languages, whenever a new version releases, it supports the features and syntax of the existing version of the language, therefore, it is easier for the projects to switch in the newer version. However, in the case of Python, the two versions Python 2 and Python 3 are very much different from each other.
A list of differences between Python 2 and Python 3 are given below:
  • Python 2 uses print as a statement and used as print "something" to print some string on the console. On the other hand, Python 3 uses print as a function and used as print("something") to print something on the console.
  • Python 2 uses the function raw_input() to accept the user's input. It returns the string representing the value, which is typed by the user. To convert it into the integer, we need to use the int() function in Python. On the other hand, Python 3 uses input() function which automatically interpreted the type of input entered by the user. However, we can cast this value to any type by using primitive functions (int(), str(), etc.).
  • In Python 2, the implicit string type is ASCII, whereas, in Python 3, the implicit string type is Unicode.
  • Python 3 doesn't contain the xrange() function of Python 2. The xrange() is the variant of range() function which returns a xrange object that works similar to Java iterator. The range() returns a list for example the function range(0,3) contains 0, 1, 2.
  • There is also a small change made in Exception handling in Python 3. It defines a keyword as which is necessary to be used. We will discuss it in Exception handling section of Python programming tutorial.
  • What is Python?
  • Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
Good to know
  • The most recent major version of Python is Python 3, which we shall be using in this tutorial. However, Python 2, although not being updated with anything other than security updates, is still quite popular.
  • In this tutorial Python will be written in a text editor. It is possible to write Python in an Integrated Development Environment, such as Thonny, Pycharm, Netbeans or Eclipse which are particularly useful when managing larger collections of Python files.
  • Python Syntax compared to other programming languages
  • Python was designed 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.