top of page

Python: Introduction

What is Python?

 

Python is a general purpose, high level programming language. Guido Van Rossam developed Python in 1989 while working with NRI (National Research Institute) in Neitherland. Officially language became available to the public in 1991.

 

General Purpose: it can be used for multiple purposes such as:

  • Data Science

  • Machine Learning

  • Robotics

  • Web applications

  • Desktop applications

High level vs Low Level Language: Human (Programmer) understandable languages like Java, Python etc are called high level languages. These languages has to be translated in machine language by a compiler or interpreter.

On the other hand, there are some languages that can directly communicate with the machine like Assembly Language, Machine Language. These languages are called low level languages and can't be easily understood by the humans.

Learning Python

  • Python is very Easy Programming language. You may call it a play school level language.

  • If  you have basic idea about any programming language then learning python is going to be very easy. But even If you don’t have any idea about any other programming language, then also don’t worry, we will make it easy for you.

  • You can learn Python as your first programing language.

When Compared with other PL Python is Easiest?

  • Just like English we can write python code.

  • Now with the help of a simple program I am going to show why python is easier than other programming language.

Example 1:

Namaste in Java

class Namaste

{

public static void main(String [ ] args)

{

System.out.print("Namaste!");

}

}

Go to the location where you saved the file

compile the code with javac

What is Pyhon
Learning Python
Python is easiest
Python vs JAVA

Then run the code with java

Python vs JAVA

Just to print a Namaste you are required to write class, a main method, println statement after that compile the code then you will be able to run a simple Namaste.

Namaste in C

#include<stdio.h>

Void main

{

printf(“Namaste!”);

}

Compile and run the program.

Namaste in Python

Just write one line of code to and run.

Coding in Python

You need not know class, main method, curly braces; nothing. Just write and run whatever you want.

If anybody wants to learn programming, it is better to start with python

Example 2:

Sum of two numbers in java

public class Sum

{

public static void main(String [ ] args)

{

            int a,b;

            a=10;

            b=20;

System.out.println(a+b);  

}                                  

}

Python vs JAVA

Sum of two numbers in C

#include<stdio.h>

Void main

{

Int a,b;

a=10;

b=20;

printf(a+b);

}

Compile and run the program.

Sum of two numbers in Python

Coding in Python
Why Name Python
What type of languge

10 assigned to 'a' , 20 assigned to 'b' and then print sum.

From these two examples you can see that it is much easier to write programmes in Python. 10-20 lines of code in other languages may be converted to just 3-4 lines of code in Python.

Why Its  Name Became Python?

There was a Popular TV show on BBC named Monty Python’s Flying Circus (1969-1974). Based on this, Guido Van Rossam decided to name the language as Python.

What Type of Language Python is?

While developing python Guido borrowed almost all the features from other languages.

1. Functional Programming from C: Write and call the function directly.

Python and C
which companes are using
where we can use

2. Object Oriented feature from C++: You can create class and Object.

3. Scripting features from Perl and Shell Script (Unix).

4. Modular programming features from Modula-3

  • Modular means dividing a program into modules.

  • Most of the syntax is taken from C language and ABC (not so popular) language.

Thus Python is an All in One Package.

Where We Can Use Python?

  1. Desktop Applications (Stand Alone Applications ): A particular system based application like Calculator. No need of Internet to run this application.

  2. Web Application: DJango to develop web application

  3. Database Application: To Connect with the Database.

  4. Networking Application

  5. Gaming Application

  6. Data Analysis Applications: To learn about data science

  7. Machine Learning Applications

  8. AI (Artificial Intelligence) Applications

  9. IoT (Internet of things) Based Applications

You can develop any type of application using Python.

Which companies are using Python?

  • Google-Search Algorithm

  • Youtube-Search

  • Dropbox: used to shared files

  • NASA in space research

  • Stock Exchange

  • National Security

  • Instagram

  • VMware

Features of Python

  • Simple and easy to learn: In comparison to other PL we can write python code in less number of lines with more readability and simplicity. We can reduce development time and cost of the project also if we choose Python. Python contains only 30 Keyword (in java there are 53 keyword).

  • Free ware: You don’t need to pay for license.

  • Open Source: You will be able to see the source code and how python is implemented. You can customize implementation and can introduce your own version of Python (like Linux).

  • High level PL: Human(Programmer) understandable language (like Java).

  • Platform Independent (WORA principle): Write Once Run Anywhere. You can write programme on any platform like windows and can run on any other platform like Mac or Linux . Assume that you write a Python programme, you can give your programme to all customers. Suppose one customer has only windows machine and want to run it on windows, second customer has Linux VM and third customer has Mac OS and some other customer has Sun Solaris, this one programme is going to work on all these platforms.

features
Features of Python
  • Portability: In olden days if you wanted to change your mobile operator like from Idea to Airtel, compulsorily you have to buy a new sim and you will get a new number. But now a days you can change your operator maintaining the same  number. This is known as Mobile Number Portability. Similarly moving python program from one plaform to another plaform without making any change, for example moving a program from windows machine to linux machine, is called portability.

Features of Python
  • Dynamically Typed: Based on your provided values type will be assigned automatically, you don’t need to worry about the type. For example if you provide a=10, by default 'a' will be considered as int. If you want to check just type type 'a'.

Features of Python

type( ) is a inbuilt function in python.

Features of Python
Features of Python

In python upto a=10, 'a' is treated as int; when you are assigning a=true, now onward a is treated as boolean. We are not required to declare the type of python variable, based on the provided value type is assigned automatically; that’s why python is dynamically typed programming language.

  • Object Oriented Type: We can use Python as Object Oriented language and take the benefits of Inheritance, Polymorphism etc.

  • Procedure Oriented: We can divide the program into functions.

  • Interpreted Language: It is an interpreted language. Interpreter can interpret one line at a time .Whenever you run Python interpreter, first its virtual misson is going  to do compilation. Syntax checking will be done and If anywhere some syntactical mistake is there, we will get syntax error. Once you correct all the syntactical error then only it is going to run. 

  • Extensible: We can use already existing code in other languague and can improve the performance of application.

  • Embeded: Python program can embed in other languages.

  • Extensive Libraries (Batteries): Python has  rich libraries (Batteries). Readymade blocks are available for almost each and everything, which can be easily imported and used as per requirement. For example, if you want to find square rootyou can import python math module and use its sqrt() function.

Features of Python

We want to write a program to generate 6 digit OTP randomly

randint() function is going to generate a random number beteen 0 to 9.

>>> from random import *

>>> print(radiant(0,9),radiant(0,9),radiant(0,9),radiant(0,9),radiant(0,9),radiant(0,9),sep=")

855431

Coding in Python

Limitations of Python

 

  1. Performance: Performance wise python is not upto the mark because it is an interpreted language. Interpreter can interpret one line at a time. Java has better performance than Python because inside JVM, JIT compiler concept is there (We  will discuss JIT compiler in the Java section of the tutorial).

  2. Mobile Applications: In mobile applications python is not upto the mark.

Flavors of Python

  1. CPython: Developed to work with C language Applications.

  2. Jython or JPython: Developed to work with Java  Applications.

  3. IronPython: Developed to work with C# , dotnet Applications.

  4. Pypy (Python for speed): It is used for high performance. In this JIT (Just in time) compiler is used because of which performance is improved.

  5. RubyPython: Developed to work with Ruby Applications.

  6. AnacondaPython: Developed to  handle Big Data.

  7. Stackless (Python for concurrency): Developed to be used for multithreading (Things are going to be executed parallelly).

limitations
flavours

For any Query/Suggestion, do let us know in the comment section.

bottom of page