SlideShare a Scribd company logo
PYTHON
A READABLE, DYNAMIC, PLEASANT,
FLEXIBLE, FAST AND POWERFUL LANGUAGE
-VEERESH NB
PYTHON
• It is the programming high level language that is applied for
scripting roles
• Python is a widely used high-level programming
language for general-purpose programming, created by Guido van
Rossum and first released in 1991.
• Python interpreters are available for many operating systems,
allowing Python code to run on a wide variety of systems.
INDEX
• Data Types
• Numbers
• Strings
• Tuples
• Lists
• Dictionaries
• Methods
• String methods
• List methods
• Dictionary methods
• Files
• Operators
• Arithmetic
• Logical
• Control Flow
• If / Elif /else
• For
• While
• Break
• Functions
• Arguments
• Lambda
• Scope
• Recursive
• Modules and
Packages
• Class
• Inheritance
• Polymorphism
DATA TYPES:
NUMBERS
Numeric type is used to store the numeric value.
var =2
Types of numeric types:
1)Integers/Floating- 1, 1/2=0, 2.4, 1.0/2=0.5
var=3.25421
print var=3.25421
2)Complex - a+bi
STRINGS
It is a sequence of characters which to be represented in
“ ”(or)’ ‘.
example :“digital”
Indexing:
The process of assigning a sequence of numbers to the element.
Example:
var =“digital”
var[0]=“d”
len(var)=will give length of string =7
TUPLES
These are immutable objects so that we can’t change values in tuple.
These are same as that of the lists.
var =(1,2,3,4)
var1=(4,5,6,7)
var + var1=(1,2,3,4,4,5,6,7)
var*3= (1,2,3,4,1,2,3,4,1,2,3,4)
LISTS
• It is the most flexible ordered collection object type. List contain any sort of object i.e;
numbers, string, other lists.
• These are mutable objects.
Example:
var =[“a”,1,2,”b”]
var1 =[3,4,5,6]
var+var1=[“a”,1,2,”b”,3,4,5,6]-concatenation
var*3=[“a”,1,2,”b”, “a”,1,2,”b”, “a”,1,2,”b”]-repetition
DICTIONARIES
• Dictionaries are one of the most flexible built in data types in python. These are
unordered collection, here the values (or) items are stored and fetched by key
instead of position offset.
• These are immutable objects.
Example: d1={“a”:1,”b”:2,”e”:3}
d2={“a”:[1,2,3],”b”:[3,4,5]}
METHODS:
STRING METHODS
i)endswith(): It will check whether the condition is true(or)false.
Example:
var=“digital”
var.endswith(“l”)=true
ii)startswith(): It also checks whether condition is true (or)false.
Example:
var.startswith(“d”)=true
Var.startswith(“i”)=false
iii)split(): It split the string with the condition.
Example:
var=“digital lync”
var.split()=[“digital”,”lync”]
var=“digital_lync”
Var.split(‘_’)=[“digital”,”_lync”]
iv)strip():It will remove escape sequences.
Example:
var=“ndigitalnlynct”
var.strip()=digital
lync
v)replace():It will replace the text with the new text.
Example: var=“digital lync”
var.replace(“c”, ”k”)=“digital link”
vi)join(): It will add symbols according to the
condition.
Example: var=“digital”
‘ ’.join(var)=“d I g I t a l”
vii)zfill(): It will provide 0’s before the number with
condition.
Example:
`num=“2435”
num.zfill(5)=“02435”
viii)lower(): It will convert upper to lower case.
Example:
new=“DIGITAL”
new.lower()=“digital”
ix)upper():It will convert lower to upper case.
Example:
new =“digital”
new.upper() =“DIGITAL”
LIST METHODS
1)append(): It is used for placing a values in list.
Example: var=[1,2,”a”,”b”]
var.append(6)=[1,2,”a”,”b”,6]
2)extend(): It is used for extending values in list.
Example: var=[1,2,”c”] var1=[3,4,5,6]
var.extend(var1)=[1,2,”c”,3,4,5,6]
3)insert(): It will insert the value with the help of index value.
Example: var.insert(0,”z”)=[“z”,1,2,”c”]
4)index():
It will return the index value of the element we specify.
Example:
var=[1,2,”a”,”b”]
var.index(“a”)=2
5)count():
It will count no.of time the element is repeated.
Example:
var=[1,2,”a”,”c”,”k”,2,”y”,”c”]
var.count(“c”)=2
6)remove():
It will remove specified element from the list.
Example:
var.remove(“a”)
7)pop():
It will remove the element and return the index value.
Example:
var=[1,2,3,”a”]
var.pop(“a”)=3
DICTIONARY METHODS
d1={“a”:1,”b”:2,”c”:3}
d2={“e”:6,”f”:7,”g”:8}
1)d1.keys():It will give the keys in d1 dictionary as [“a”, ”b”, ”c”]
2)d1.values():It will give only values in d1 dictionary as [1,2,3]
3)d1.items():It will give the items in d1 dictionary as [(“a”,1),(“b”,2),(“c”,3)]
4)update():It will update the items in d1 with the items in d2.
Example: d1.update(d2)={“a”:1,”b”:2,”c”:3,”d”:4,”e”:5,”f”:6}
5)pop():It will remove the key item from dictionary and returns key value associated with the key item
Example: d2={“d”:4,”e”:5,”f”:6}
d2.pop(“f”)= 6
FILES
A FILE IS A COLLECTION OF DATA STORED IN ONE UNIT.
Modes:
read-”r” write-”w” append-”a” read and write-”r+”
Read: Its for reading the content in a file
var=open(“F:test.txt”,”r”)
print var.readline()
var.close()
print var.readlines()
Write: Its for writing into the file.
var = open(“F://test.txt”,”w”)
print var.write(“This is india”)
var.close()
append: It will add content to the previous lines in the file.
var =open(“F:test.txt”,”a”)
print var.write(“nhelloworld”)
var.close()
Read and write: It will perform both read and write operation.
var =open(“F:test.txt”,”r+”)
print var.readline()
print var.write(“helloworld”)
var.close()
OPERATORS
ARITHMETIC OPERATIONS
• Addition (a+b)
• Subtraction (a-b)
• Multiplication (a*b)
• Division (a/b)
• Modulus a%b
• Power (a**b)
LOGICAL OPERATIONS
• Greater then >
• Less than <
• Greater than or Equal to >=
• Less than or Equal to <=
• Equals to ==
• Not Equals to !=
CONTROL FLOW:
If-elif-else:
It is a conditional statement which is
use for selecting action.
Syntax:
if expression1:
statement()
elif expression2:
statement()
else:
statement()
While:
It is the general iteration construct
because it repeatedly execute blocks of
statements as long as the condition is “true”.
Syntax:
while condition:
statement
Break:
Jump out of the closest enclosing loop.
Continue:
Jump to the top the closest enclosing
loop.
Pass:
Pass is a no operation place holder which
is used to code a body of empty statement
Example:
i=1
j=int(raw_input('Enter a number:'))
while i<=j:
print ' *'*i
i+=1
Enter a number:5
*
* *
* * *
* * * *
* * * * *
FOR LOOP
For is the looping statement which can step through the items in order sequence from
list having strings, tuples and other built in objects
Example:
for x in range(0, 5)
print x
1
2
3
4
5
FUNCTIONS
Functions are defined using the def keyword. After this keyword comes an identifier name for the function,
followed by a pair of parentheses which may enclose some names of variables, and by the final colon that ends the
line. Next follows the block of statements that are part of this function. An example will show that this is actually very
simple
Example:
def operations_union(A,B):
for item in B:
if item in A:
continue
else:
A.append(item)
return A
A= [1,2,3,4]
B= [3,4,5,6]
print operations_union(A,B)
Lambda:
• var=lambda x,y: x+y
print var(2,3)
SCOPE:
x='digital'
def scope_1():
global x
x= 'lync'
def scope_2():
x='school'
print x
scope_2()
scope_1()
print x
Recursive:
def factorial(n):
if n==0:
return 1
else:
return n * factorial(n-1)
a = int(raw_input('Enter a number:'))
print factorial(a)
Enter a number:5
120
MODULES AND PACKAGES
Module can be imported by another program to make use of its
functionality. This is how we can use the Python standard library as well. First, we
will see how to use the standard library modules.
Builtin: import file_name
from
Example: file_a.py file_b.py
def stmnt(): import file_a
Return
OBJECT ORIENTED PROGRAMMING
CLASS
Classes and objects are the two main aspects of object oriented
programming. A class creates a new type where objects are instances of the
class. An analogy is that you can have variables of type int which translates to
saying that variables that store integers are variables which are instances
(objects) of the int class.
SELF:
Self is the name commonly giving to the first left most argument in a class
method.
Python can automatically fills it in with the instance object
SYNTAX
• class calculator:
def __init__(self,var1,var2):
self.num1 = var1
self.num2 = var2
def add(self):
return self.num1+self.num2
I= calculator(2, 3)
I.add()

More Related Content

What's hot

Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
Steve Johnson
 
Python basics
Python basicsPython basics
Python basics
Hoang Nguyen
 
C++ theory
C++ theoryC++ theory
C++ theory
Shyam Khant
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
Sujith Kumar
 
C language
C languageC language
C language
umesh patil
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
Eelco Visser
 
C
CC
More on Lex
More on LexMore on Lex
More on Lex
Tech_MX
 
Python language data types
Python language data typesPython language data types
Python language data types
Hoang Nguyen
 
python codes
python codespython codes
python codes
tusharpanda88
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
Eelco Visser
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
Sami Said
 
Chapter 10 Library Function
Chapter 10 Library FunctionChapter 10 Library Function
Chapter 10 Library Function
Deepak Singh
 
Python- Regular expression
Python- Regular expressionPython- Regular expression
Python- Regular expression
Megha V
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
Eelco Visser
 
Python ppt
Python pptPython ppt
Python ppt
Anush verma
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
Eelco Visser
 
LEX & YACC TOOL
LEX & YACC TOOLLEX & YACC TOOL
Unix Tutorial
Unix TutorialUnix Tutorial
Unix Tutorial
Sanjay Saluth
 
Functions in python
Functions in pythonFunctions in python
Functions in python
Santosh Verma
 

What's hot (20)

Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
Python basics
Python basicsPython basics
Python basics
 
C++ theory
C++ theoryC++ theory
C++ theory
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
C language
C languageC language
C language
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
C
CC
C
 
More on Lex
More on LexMore on Lex
More on Lex
 
Python language data types
Python language data typesPython language data types
Python language data types
 
python codes
python codespython codes
python codes
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
Chapter 10 Library Function
Chapter 10 Library FunctionChapter 10 Library Function
Chapter 10 Library Function
 
Python- Regular expression
Python- Regular expressionPython- Regular expression
Python- Regular expression
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
Python ppt
Python pptPython ppt
Python ppt
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
 
LEX & YACC TOOL
LEX & YACC TOOLLEX & YACC TOOL
LEX & YACC TOOL
 
Unix Tutorial
Unix TutorialUnix Tutorial
Unix Tutorial
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 

Similar to Introduction to Python , Overview

Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
Utkarsh Sengar
 
Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)
Roy Zimmer
 
Phyton Learning extracts
Phyton Learning extracts Phyton Learning extracts
Phyton Learning extracts
Pavan Babu .G
 
Python basics
Python basicsPython basics
Python basics
Young Alista
 
Python basics
Python basicsPython basics
Python basics
Fraboni Ec
 
Python basics
Python basicsPython basics
Python basics
Harry Potter
 
Python basics
Python basicsPython basics
Python basics
James Wong
 
Python basics
Python basicsPython basics
Python basics
Tony Nguyen
 
Python basics
Python basicsPython basics
Python basics
Luis Goldster
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developers
Jim Roepcke
 
PythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdfPythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdf
data2businessinsight
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : Python
Raghu Kumar
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
Sami Said
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
Maulik Borsaniya
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
Sudharsan S
 
Tut1
Tut1Tut1
Python Basics
Python BasicsPython Basics
Python Basics
tusharpanda88
 
Perl tutorial final
Perl tutorial finalPerl tutorial final
Perl tutorial final
Ashoka Vanjare
 
Erlang session1
Erlang session1Erlang session1
Erlang session1
mohamedsamyali
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
rik0
 

Similar to Introduction to Python , Overview (20)

Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)
 
Phyton Learning extracts
Phyton Learning extracts Phyton Learning extracts
Phyton Learning extracts
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developers
 
PythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdfPythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdf
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : Python
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
Tut1
Tut1Tut1
Tut1
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Perl tutorial final
Perl tutorial finalPerl tutorial final
Perl tutorial final
 
Erlang session1
Erlang session1Erlang session1
Erlang session1
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 

Recently uploaded

Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
kalichargn70th171
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
kgyxske
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
Severalnines
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabhQuarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
aisafed42
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
Envertis Software Solutions
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 

Recently uploaded (20)

Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabhQuarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 

Introduction to Python , Overview

  • 1. PYTHON A READABLE, DYNAMIC, PLEASANT, FLEXIBLE, FAST AND POWERFUL LANGUAGE -VEERESH NB
  • 2. PYTHON • It is the programming high level language that is applied for scripting roles • Python is a widely used high-level programming language for general-purpose programming, created by Guido van Rossum and first released in 1991. • Python interpreters are available for many operating systems, allowing Python code to run on a wide variety of systems.
  • 3. INDEX • Data Types • Numbers • Strings • Tuples • Lists • Dictionaries • Methods • String methods • List methods • Dictionary methods • Files • Operators • Arithmetic • Logical • Control Flow • If / Elif /else • For • While • Break • Functions • Arguments • Lambda • Scope • Recursive • Modules and Packages • Class • Inheritance • Polymorphism
  • 4. DATA TYPES: NUMBERS Numeric type is used to store the numeric value. var =2 Types of numeric types: 1)Integers/Floating- 1, 1/2=0, 2.4, 1.0/2=0.5 var=3.25421 print var=3.25421 2)Complex - a+bi
  • 5. STRINGS It is a sequence of characters which to be represented in “ ”(or)’ ‘. example :“digital” Indexing: The process of assigning a sequence of numbers to the element. Example: var =“digital” var[0]=“d” len(var)=will give length of string =7
  • 6. TUPLES These are immutable objects so that we can’t change values in tuple. These are same as that of the lists. var =(1,2,3,4) var1=(4,5,6,7) var + var1=(1,2,3,4,4,5,6,7) var*3= (1,2,3,4,1,2,3,4,1,2,3,4)
  • 7. LISTS • It is the most flexible ordered collection object type. List contain any sort of object i.e; numbers, string, other lists. • These are mutable objects. Example: var =[“a”,1,2,”b”] var1 =[3,4,5,6] var+var1=[“a”,1,2,”b”,3,4,5,6]-concatenation var*3=[“a”,1,2,”b”, “a”,1,2,”b”, “a”,1,2,”b”]-repetition
  • 8. DICTIONARIES • Dictionaries are one of the most flexible built in data types in python. These are unordered collection, here the values (or) items are stored and fetched by key instead of position offset. • These are immutable objects. Example: d1={“a”:1,”b”:2,”e”:3} d2={“a”:[1,2,3],”b”:[3,4,5]}
  • 9. METHODS: STRING METHODS i)endswith(): It will check whether the condition is true(or)false. Example: var=“digital” var.endswith(“l”)=true ii)startswith(): It also checks whether condition is true (or)false. Example: var.startswith(“d”)=true Var.startswith(“i”)=false
  • 10. iii)split(): It split the string with the condition. Example: var=“digital lync” var.split()=[“digital”,”lync”] var=“digital_lync” Var.split(‘_’)=[“digital”,”_lync”] iv)strip():It will remove escape sequences. Example: var=“ndigitalnlynct” var.strip()=digital lync v)replace():It will replace the text with the new text. Example: var=“digital lync” var.replace(“c”, ”k”)=“digital link” vi)join(): It will add symbols according to the condition. Example: var=“digital” ‘ ’.join(var)=“d I g I t a l” vii)zfill(): It will provide 0’s before the number with condition. Example: `num=“2435” num.zfill(5)=“02435” viii)lower(): It will convert upper to lower case. Example: new=“DIGITAL” new.lower()=“digital” ix)upper():It will convert lower to upper case. Example: new =“digital” new.upper() =“DIGITAL”
  • 11. LIST METHODS 1)append(): It is used for placing a values in list. Example: var=[1,2,”a”,”b”] var.append(6)=[1,2,”a”,”b”,6] 2)extend(): It is used for extending values in list. Example: var=[1,2,”c”] var1=[3,4,5,6] var.extend(var1)=[1,2,”c”,3,4,5,6] 3)insert(): It will insert the value with the help of index value. Example: var.insert(0,”z”)=[“z”,1,2,”c”]
  • 12. 4)index(): It will return the index value of the element we specify. Example: var=[1,2,”a”,”b”] var.index(“a”)=2 5)count(): It will count no.of time the element is repeated. Example: var=[1,2,”a”,”c”,”k”,2,”y”,”c”] var.count(“c”)=2 6)remove(): It will remove specified element from the list. Example: var.remove(“a”) 7)pop(): It will remove the element and return the index value. Example: var=[1,2,3,”a”] var.pop(“a”)=3
  • 13. DICTIONARY METHODS d1={“a”:1,”b”:2,”c”:3} d2={“e”:6,”f”:7,”g”:8} 1)d1.keys():It will give the keys in d1 dictionary as [“a”, ”b”, ”c”] 2)d1.values():It will give only values in d1 dictionary as [1,2,3] 3)d1.items():It will give the items in d1 dictionary as [(“a”,1),(“b”,2),(“c”,3)] 4)update():It will update the items in d1 with the items in d2. Example: d1.update(d2)={“a”:1,”b”:2,”c”:3,”d”:4,”e”:5,”f”:6} 5)pop():It will remove the key item from dictionary and returns key value associated with the key item Example: d2={“d”:4,”e”:5,”f”:6} d2.pop(“f”)= 6
  • 14. FILES A FILE IS A COLLECTION OF DATA STORED IN ONE UNIT. Modes: read-”r” write-”w” append-”a” read and write-”r+” Read: Its for reading the content in a file var=open(“F:test.txt”,”r”) print var.readline() var.close() print var.readlines() Write: Its for writing into the file. var = open(“F://test.txt”,”w”) print var.write(“This is india”) var.close() append: It will add content to the previous lines in the file. var =open(“F:test.txt”,”a”) print var.write(“nhelloworld”) var.close() Read and write: It will perform both read and write operation. var =open(“F:test.txt”,”r+”) print var.readline() print var.write(“helloworld”) var.close()
  • 15. OPERATORS ARITHMETIC OPERATIONS • Addition (a+b) • Subtraction (a-b) • Multiplication (a*b) • Division (a/b) • Modulus a%b • Power (a**b) LOGICAL OPERATIONS • Greater then > • Less than < • Greater than or Equal to >= • Less than or Equal to <= • Equals to == • Not Equals to !=
  • 16. CONTROL FLOW: If-elif-else: It is a conditional statement which is use for selecting action. Syntax: if expression1: statement() elif expression2: statement() else: statement()
  • 17. While: It is the general iteration construct because it repeatedly execute blocks of statements as long as the condition is “true”. Syntax: while condition: statement Break: Jump out of the closest enclosing loop. Continue: Jump to the top the closest enclosing loop. Pass: Pass is a no operation place holder which is used to code a body of empty statement Example: i=1 j=int(raw_input('Enter a number:')) while i<=j: print ' *'*i i+=1 Enter a number:5 * * * * * * * * * * * * * * *
  • 18. FOR LOOP For is the looping statement which can step through the items in order sequence from list having strings, tuples and other built in objects Example: for x in range(0, 5) print x 1 2 3 4 5
  • 19. FUNCTIONS Functions are defined using the def keyword. After this keyword comes an identifier name for the function, followed by a pair of parentheses which may enclose some names of variables, and by the final colon that ends the line. Next follows the block of statements that are part of this function. An example will show that this is actually very simple Example: def operations_union(A,B): for item in B: if item in A: continue else: A.append(item) return A A= [1,2,3,4] B= [3,4,5,6] print operations_union(A,B)
  • 20. Lambda: • var=lambda x,y: x+y print var(2,3) SCOPE: x='digital' def scope_1(): global x x= 'lync' def scope_2(): x='school' print x scope_2() scope_1() print x Recursive: def factorial(n): if n==0: return 1 else: return n * factorial(n-1) a = int(raw_input('Enter a number:')) print factorial(a) Enter a number:5 120
  • 21. MODULES AND PACKAGES Module can be imported by another program to make use of its functionality. This is how we can use the Python standard library as well. First, we will see how to use the standard library modules. Builtin: import file_name from Example: file_a.py file_b.py def stmnt(): import file_a Return
  • 22. OBJECT ORIENTED PROGRAMMING CLASS Classes and objects are the two main aspects of object oriented programming. A class creates a new type where objects are instances of the class. An analogy is that you can have variables of type int which translates to saying that variables that store integers are variables which are instances (objects) of the int class. SELF: Self is the name commonly giving to the first left most argument in a class method. Python can automatically fills it in with the instance object
  • 23. SYNTAX • class calculator: def __init__(self,var1,var2): self.num1 = var1 self.num2 = var2 def add(self): return self.num1+self.num2 I= calculator(2, 3) I.add()