PYTHON
LECTURE 1
Today’s Agenda
An Introduction to Python
• Necessity Of Programming
• What Is Python ?
• Why And Who Created It ?
• What Python Can Do ?
• Why Should I Learn Python In 2020 ?
• Important Features
Why Do We Need Programming ?
• To communicate with digital machines and make them
work accordingly
• Today in the programming world , we have more than
800 languages available.
• And every language is designed to fulfill a particular
kind of requirement
Brief History Of Prog. Lang
⚫ C language was primarily designed to develop “System
Softwares” like Operating Systems, Device Drivers etc .
⚫ To remove security problems with “C” language , C++
language was designed.
⚫ It is an Object Oriented Language which provides data
security and can be used to solve real world problems.
⚫ Many popular software like Adobe Acrobat , Winamp Media
Player,Internet Explorer,Mozilla Firefox etc were designed in
C++
Courtsey:http://www.stroustrup.com/applications.html
What is Python ?
⚫ Python is a general purpose and powerful
programming language.
⚫ Python is considered as one of the most versatile
programming language as it can be used to develop
almost any kind of application including desktop
application , web applications , CAD , Image
processing and many more.
Who created Python ?
⚫ Developed by Guido Van
Rossum , a Dutch scientist
⚫ Created at Center For
Mathematics and
Research , Netherland
⚫ It is inspired by another
programming language called
ABC
Why was Python
created ?
⚫ Guido started Python
development as a hobby in
1989
⚫ But since then it has grown to
become one of the most
polished languages of the
computing world.
How Python got
it’s name?
⚫ The name Python is inspired
from Guido’s favorite
Comedy TV show called
“Monty Python’s Flying
Circus”
⚫ Guido wanted a name that was
short, unique, and slightly
mysterious, so he decided to
call the language Python.
Who manages Python
today ?
⚫ From version 2.1 onwards ,
python is managed by Python
Software Foundation
situated in Delaware , USA
⚫ It is a non-profit
organization devoted to the
growth and enhancement of
Python language
⚫ Their website is
http://www.python.org
What Python can do ?
⚫ GUI Application
⚫ Web Application
⚫ Data Analysis
⚫ Machine Learning
⚫ Raspberry Pi
⚫ Game Development
GUI In Python
⚫ Python is used for GUI
apps all the time.
⚫ It has famous libraries
like PyQT , Tkinter to
build desktop apps.
Web Application
In Python
⚫ We can use Python to
create web applications
on many levels of
complexity
⚫ There are many
excellent Python
frameworks like
Django, Pyramid and
Flask for this purpose
Data Analysis In Python
⚫ Data Analysis is
about making
predictions with
data
⚫ Python is the leading
language of choice for
many data scientists
⚫ It has grown in
popularity due to it’s
excellent libraries like
Numpy , Pandas etc
Machine Learning
In Python
⚫ Machine learning is a field of
AI (Artificial
Intelligence) by using
which software
applications can learn to
increase their accuracy for
the expecting outcomes.
⚫ It is heavily used in Face
recognition , music
recommendation ,
medical data etc
⚫ Python has many wonderful
libraries to implement ML
algos like SciKit-Learn ,
Tensorflow etc
Raspberry Pi
In Python
⚫ The Raspberry Pi is a
low cost, credit-card
sized computer that
plugs into a computer
monitor or TV, and uses
a standard keyboard
and mouse.
⚫ It can do almost
everything a normal
desktop can do
Raspberry Pi
In Python
⚫ We can build Home
Automation System and
even robots using
Raspberry-Pi
⚫ The coding on a
Raspberry Pi can be
performed using Python
Game Development
In Python
⚫ We can write
whole games in Python
using PyGame.
⚫ Popular games
developed in Python
are:
⚪ Bridge Commander
⚪ Civilization IV
⚪ Battlefield 2
⚪ Eve Online
⚪ Freedom Force
Why should
I learn Python ?
⚫ 3rd most popular programming
⚫ Fastest growing language
⚫ Opens lots of doors
⚫ Big corporates prefer Python
⚫ Means , PYTHON IS THE
FUTURE
Who uses Python
today ?
Features Of Python
⚫ Simple
⚫ Dynamically Typed
⚫ Robust
⚫ Supports multiple programming paradigms
⚫ Compiled as well as Interpreted
⚫ Cross Platform
⚫ Extensible
⚫ Embedded
⚫ Extensive Library
Simple
⚫ Python is very simple
⚫ As compared to other popular languages like Java and
C++, it is easier to code in Python.
⚫ Python code is comparitively 3 to 5 times smaller than
C/C++/Java code
Print Hello Satna!
IN C
#include <stdio.h>
int main(){
printf("Hello Satna!");
return 0;
}
IN JAVA
public class HelloWorld{
public static void main( String[] args ) {
System.out.println( "Hello Satna!" );
}
}
IN PYTHON
print('Hello Satna!')
Swap 2 Nos
IN C
int a=10,b=20,temp;
temp=a;
a=b;
b=temp;
IN JAVA
int a=10,b=20,temp;
temp=a;
a=b;
b=temp;
IN PYTHON
a,b=10,20
a,b=b,a
Add 2 Nos
IN C
#include <stdio.h>
int main(){
int a=10,b=20;
printf(“Sum is %d”,a+b);
return 0;
}
IN JAVA
public class HelloWorld{
public static void main( String[] args ) {
int a=10,b=20;
System.out.println( “Sum is “+(a+b));
}
}
IN PYTHON
a,b=10,20
print(“Sum is”,a+b)
Dynamically Typed
Dynamically Typed
IN C IN Python
int a;
a=10
a=10;
a=“Bhopal”; a=“Bhopal”
Robust
⚫ Python has very strict rules which every program must
compulsorily follow and if these rules are violated then Python
terminates the code by generating “Exception”
⚫ To understand python’s robustness , guess the output of the
following /C++ code:
int arr[5];
int i;
for(i=0;i<=9;i++)
{
arr[i]=i+1;
}
Robust
⚫ In Python if we write the same code then it will generate
Exception terminating the code
⚫ Due to this other running programs on the computer do not
get affected and the system remains safe and secure
Supports Multiple
Programming Paradigms
⚫ Python supports both procedure-oriented and
object-oriented programming which is one of the key
python features.
⚫ In procedure-oriented languages, the program is built
around procedures or functions which are nothing but
reusable pieces of programs.
⚫ In object-oriented languages, the program is built
around objects which combine data and functionality
Compiled
As Well As Interpreted
⚫ Python uses both a compiler as well as interpreter for
converting our source and running it
⚫ However , the compilation part is hidden from the
programmer ,so mostly people say it is an interpreted
language
Cross Platform
⚫ Let’s assume we’ve written a Python code for our
Windows machine.
⚫ Now, if we want to run it on a Mac, we don’t need to make
changes to it for the same.
⚫ In other words, we can take one code and run it on any
machine, there is no need to write different code for
different machines.
⚫ This makes Python a cross platform language
Extensible
⚫ Python allows us to call C/C++/Java code from a Python
code and thus we say it is an extensible language
⚫ We generally use this feature when we need a critical piece
of code to run very fast .
⚫ So we can code that part of our program in C or C++ and
then use it from our Python program.
Embedded
⚫ We just saw that we can put code in other languages in our
Python source code.
⚫ However, it is also possible to put our Python code in a
source code in a different language like C++.
⚫ This allows us to integrate Python feature into our program
of the other language.
Extensive Library
⚫ The Python Standard Library is huge indeed.
⚫ It can help you do various things like Database
Programming , E-mailing ,GUI Programming etc