SlideShare a Scribd company logo
1 of 23
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 LanguageSteve Johnson
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in PythonSujith Kumar
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesEelco Visser
 
More on Lex
More on LexMore on Lex
More on LexTech_MX
 
Python language data types
Python language data typesPython language data types
Python language data typesHoang Nguyen
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingEelco 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 FunctionDeepak Singh
 
Python- Regular expression
Python- Regular expressionPython- Regular expression
Python- Regular expressionMegha V
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionEelco Visser
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsEelco Visser
 

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 WayUtkarsh 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
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developersJim Roepcke
 
PythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdfPythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdfdata2businessinsight
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : PythonRaghu Kumar
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manualSami 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
 
Pydiomatic
PydiomaticPydiomatic
Pydiomaticrik0
 

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

What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Recently uploaded (20)

What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 

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()