SlideShare a Scribd company logo
Python
What is Python?
 High- level language.
 Object oriented
 Interpreted
 Server scripting language.
Designed by Guido Van
Rossum in 1989.
Developer
Why Python?
 Designed to be easy to learn and master.
- Clean and clear syntax
- Very few keywords
 Highly portable.
-Runs almost everywhere
 Extensible.
 Reduced development Time
-code is 2-10x shorter than C,C++ and Java.
Comparison
Who uses
Python?
 Google
 Yahoo
 NASA
 PBS
 ….the list goes on
Applications
 Software Development
 Web developments and its applications
 Mobile applications
 Embedded devices
 Networking programming
Python Interpreter
$gedit file.py (mainly used in linux)
$ python file.py
or
$python
Variables
Syntax: variable_name = value
>>> answer = 42
>>> PI = 3.14
>>> team = ‘B25’
>>> truthy = True
>>> falsey = False
>>> nil = None
>>> choice = ‘a’
Data Types
>>> type(1)
<type ‘int’>
>>> type(PI)
<type ‘float’>
>>> type(team)
<type ‘str’>
>>> type(truthy)
<type ‘bool’>
>>> type(falsey)
<type ‘bool’>
>>> type(nil)
<type ‘NoneType’>
Note: ’type’ keyword return the
type of data it receives as
argument.
Comments
Single Line Comment Multiple Line Comment
# I Love Python
# Python uses interpreter
""" It is easy to initialize a
variable using python"""
Indentation
IndentationError: expected an
indented block
Compiles
def spam(a):
pizza = pizza + a
return pizza
print spam(5)
def spam(a):
pizza = pizza + a
return pizza
print spam(5)
Arithmetic and logical
operators
Addition
>>> print 6+1
7
Substraction
>>>print 6-2
4
Multiplication
>>>print 3*2
6
Division
>>>print 10/2
5
Exponentiation
(**)
>>> print 2 ** 10
1024
>>> print 3.0**2
9.0
Modulo(%)
>>>print 3%2
1
>>>print 5%3
2
Strings
>>>hi=“Hello World”
>>>print hi
Hello World
>>>sem=“Hangman”
Indexing In Strings
>>> hi='hello Jarvis'
>>> print hi[-1]
s
String Concatenation
String concatenation is a process in which two strings are merged together.
’+’ operator is used for concatenation.
Example:
>>>message=“Hello”
>>>messageone=“Jharvard”
>>>print message + messageone
HelloJharvard
>>>h=“python”
>>> a=2
>>>print h +str(a)
python2
Control Flow
>>>var = 100
>>>if var == 200:
print “PLUTO"
print var
>>>elif var == 100:
print "DONALD"
print var
>>>else:
print "DAISY"
print var
OUTPUT:
DONALD
100
Example:
Loops
For……
for <item> in <collection>: #Syntax
<body>
>>>for letter in 'Python': # First Example
print 'Current Letter :', letter
Current Letter : P
Current Letter : y
Current Letter : t
Current Letter : h
Current Letter : o
Current Letter : n
While………
>>>def factorial(n):
num = 1
while n >= 1:
num = num * n
n = n - 1
return num
>>>fact(5)
120
Functions
Function Syntax:
The Python interpreter has a number of functions built into it that are
available. But if the user want to define his own function he must
def factorial(arg):
num=1
while(arg>=1):
num=arg*num
arg=arg-1
return num
Example:
>>>factorial(5)
120
Data Structures
Data Structures in python usually consist of Compound Data
types.. These data types are of three categorizes:
1.Tuples
2.Lists
3.Dictionaries
Tuples
A tuple is an immutable sequence of elements.
Created with ().
>>>a=(1,8,5,4,6)
>>>print a
(1,8,5,4,6)
For Singleton Tuple we use :
>>>a=(1,)
>>>print a
(1)
>>>del tuplename #delete the tuple
Lists
• Look a lot like tuples
– Ordered sequence of values, each identified by an index
– Use [1,2,3] rather than (1,2, 3)
– Singletons are now just [4] rather than (4, )
• BIG DIFFERENCE
– Lists are mutable!!
– While tuple, int, float, str are immutable
– So lists can be modified after they are created!
len(list)
max(list)
min(list)
list.append(obj)
list.count(obj)
list.index(obj)
list.reverse()
list.remove(obj)
list.insert(i,obj)
list.pop([i])
list.sort()
List Methods:
Example:
>>>lst=[5,8,3,4,6,4]
>>>print len(lst)
>>>print max(lst)
>>>print min(lst)
>>>lst.append(10)
>>>print lst
>>>print lst.count(4)
>>>lst.reverse()
>>>print lst
>>>lst.remove(6)
>>>print lst
>>>lst.insert(1,0)
>>>print lst
>>>print lst.pop(3)
>>>lst.sort()
>>>print lst
Output:
6
8
3
[5, 8, 3, 4, 6, 4, 10]
2
[10, 4, 6, 4, 3, 8, 5]
[10, 4, 4, 3, 8, 5]
[10, 0, 4, 4, 3, 8, 5]
4
[0, 3, 4, 5, 8, 10]
Dictionary
Dictionary is an unordered set of key:value pairs.
Key are always unique to values.
Use {} curly brackets to construct the dictionary,and [] square
brackets to index it.
d = {'key1' : 1, 'key2' : 2, 'key3' : 3}
Monthly_numbers={‘Jan’:1, ’Feb’:2, ’Mar’:3,
1 :’Jan’, 2 :’Feb’,3 :’Mar’}
>>>Monthly_numbers[‘Feb’]
2
Syntax:
Dictionary methods
● clear()
● copy()
● has_key()
● keys()
● pop()
● values()
● del dict_name[key_name]
● dict_nme[key_name]=value
What do you mean by Range()
in python?
In python range () is a function that is used as a
shortcut for generating list.
It is of 3 different types:
1.range(start,stop)
2.range(stop)
3.range(start ,stop,step)
Examples:
>>>range(5,10)
[5,6,7,8,9] #last element will not be included
>>>range(5,10,2)
[5,7,9]
>>>range(5)
[0,1,2,3,4]
Importing Modules
 import <module_name>
 from <module_name> import <module>
 from <module_name> import *
A module is a python file that (generally) has only definitions of
variables, functions, and classes.
Example:
>> import math
>>> print math.sqrt(25)
5
>>> from math import *
>>> sqrt(36)
6
>>>pi
3.145926535897931
>>>from datetime import datetime
>>>now=datetime.now()
>>>now.year
2015
>>>now.month
7
>>>now.day
21
Thank You!

More Related Content

What's hot (20)

PPT
Introduction to Python - Part Two
amiable_indian
 
PDF
AmI 2017 - Python basics
Luigi De Russis
 
PDF
Python Basics
tusharpanda88
 
PPTX
Introduction to the basics of Python programming (part 3)
Pedro Rodrigues
 
PDF
AmI 2015 - Python basics
Luigi De Russis
 
PPTX
Intro to Python Programming Language
Dipankar Achinta
 
PPTX
Python language data types
Hoang Nguyen
 
PPTX
Programming in Python
Tiji Thomas
 
PDF
Let’s Learn Python An introduction to Python
Jaganadh Gopinadhan
 
PPTX
Python for Beginners(v1)
Panimalar Engineering College
 
PPT
python.ppt
shreyas_test_1234
 
PPTX
Basic Python Programming: Part 01 and Part 02
Fariz Darari
 
PPTX
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
PPTX
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
Maulik Borsaniya
 
PDF
Python cheat-sheet
srinivasanr281952
 
PPTX
PPT on Data Science Using Python
NishantKumar1179
 
PPTX
Python
Gagandeep Nanda
 
PDF
AmI 2016 - Python basics
Luigi De Russis
 
PPTX
Learn Python The Hard Way Presentation
Amira ElSharkawy
 
PPTX
Python in 30 minutes!
Fariz Darari
 
Introduction to Python - Part Two
amiable_indian
 
AmI 2017 - Python basics
Luigi De Russis
 
Python Basics
tusharpanda88
 
Introduction to the basics of Python programming (part 3)
Pedro Rodrigues
 
AmI 2015 - Python basics
Luigi De Russis
 
Intro to Python Programming Language
Dipankar Achinta
 
Python language data types
Hoang Nguyen
 
Programming in Python
Tiji Thomas
 
Let’s Learn Python An introduction to Python
Jaganadh Gopinadhan
 
Python for Beginners(v1)
Panimalar Engineering College
 
python.ppt
shreyas_test_1234
 
Basic Python Programming: Part 01 and Part 02
Fariz Darari
 
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
Maulik Borsaniya
 
Python cheat-sheet
srinivasanr281952
 
PPT on Data Science Using Python
NishantKumar1179
 
AmI 2016 - Python basics
Luigi De Russis
 
Learn Python The Hard Way Presentation
Amira ElSharkawy
 
Python in 30 minutes!
Fariz Darari
 

Similar to Python-The programming Language (20)

PDF
ppt_pspp.pdf
ShereenAhmedMohamed
 
PPT
Getting started in Python presentation by Laban K
GDSCKYAMBOGO
 
PPTX
Python_IoT.pptx
SwatiChoudhary95
 
PDF
Python Part 1
Mohamed Ramadan
 
PPT
Python tutorialfeb152012
Shani729
 
PPTX
Basic of Python- Hands on Session
Dharmesh Tank
 
ODP
Python slide.1
Aswin Krishnamoorthy
 
PPTX
Phython presentation
karanThakur305665
 
PPTX
Python Workshop
Assem CHELLI
 
PPTX
funadamentals of python programming language (right from scratch)
MdFurquan7
 
PPT
Python
Vishal Sancheti
 
PPTX
Python bible
adarsh j
 
PDF
Introduction to python
Ahmed Salama
 
PPTX
1. python programming
sreeLekha51
 
PDF
Python: An introduction A summer workshop
ForrayFerenc
 
PPTX
Parts of python programming language
Megha V
 
PPTX
Python unit 2 is added. Has python related programming content
swarna16
 
PPTX
1664611760basics-of-python-for begainer1 (3).pptx
krsonupandey92
 
PPTX
FUNDAMENTALS OF PYTHON LANGUAGE
Saraswathi Murugan
 
PPTX
Pythonppt28 11-18
Saraswathi Murugan
 
ppt_pspp.pdf
ShereenAhmedMohamed
 
Getting started in Python presentation by Laban K
GDSCKYAMBOGO
 
Python_IoT.pptx
SwatiChoudhary95
 
Python Part 1
Mohamed Ramadan
 
Python tutorialfeb152012
Shani729
 
Basic of Python- Hands on Session
Dharmesh Tank
 
Python slide.1
Aswin Krishnamoorthy
 
Phython presentation
karanThakur305665
 
Python Workshop
Assem CHELLI
 
funadamentals of python programming language (right from scratch)
MdFurquan7
 
Python bible
adarsh j
 
Introduction to python
Ahmed Salama
 
1. python programming
sreeLekha51
 
Python: An introduction A summer workshop
ForrayFerenc
 
Parts of python programming language
Megha V
 
Python unit 2 is added. Has python related programming content
swarna16
 
1664611760basics-of-python-for begainer1 (3).pptx
krsonupandey92
 
FUNDAMENTALS OF PYTHON LANGUAGE
Saraswathi Murugan
 
Pythonppt28 11-18
Saraswathi Murugan
 
Ad

Recently uploaded (20)

PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PDF
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PDF
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PDF
Digital water marking system project report
Kamal Acharya
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
Distribution reservoir and service storage pptx
dhanashree78
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
Digital water marking system project report
Kamal Acharya
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
Ad

Python-The programming Language