SlideShare a Scribd company logo
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
What is Hadoop?
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Agenda
➢ Python Introduction
➢ Who uses Python?
➢ Python Features
➢ Operators in Python
➢ Datatypes in Python
➢ Flow Control
➢ Functions in Python
➢ File Handling in Python
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Python Introduction
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Python Introduction
➢ Python is an interpreted, object-oriented, high-level programming language
with dynamic semantics
➢ Python was created by Guido Rossum in 1989 and is very easy to learn
Procedure
Oriented
Object
Oriented
Easy to
Learn
High Level
Language
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Who uses Python?
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Who Uses Python?
The popular YouTube video
sharing service is largely
written in Python.
C O M P A N I E S U S I N G P Y T H O N
Google makes extensive use of
Python in its web search
systems.
The Raspberry Pi single-
board computer promotes
Python as its educational
language.
Dropbox storage service
codes both its server and
desktop client software
primarily in Python.
BitTorrent peer-to-peer file
sharing system began its life
as a Python program.
NASA, Los Alamos, Fermilab,
JPL, and others use Python
for scientific programming
tasks.
The NSA uses Python for
cryptography and
intelligence analysis.
Netflix and Yelp have both
documented the role of
Python in their software
infrastructures.
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Python Features
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Python Features
Simple and Easy to Learn
Free and Open Source
Python is a simple and easy to learn, read & write
Python is an example of a FLOSS (Free/Libre and Open Source
Software) which means one can freely distribute copies of this
software, read it's source code, modify it, etc.
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Python Features
High-level Language
Portable
One does not need to bother about the low-level details
like memory allocation, etc. while writing Python
script
Supported by many platforms like Linux, Windows, FreeBSD,
Macintosh, Solaris, OS/2, Amiga, AROS, AS/400, BeOS, OS/390,
PlayStation, Windows CE, etc.
a=3
b=5
sum=a+b
print(sum)
01001010110110
11101100001101
10110101100101
0101011010
compile
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Python Features
Python code can invoke C and C++ libraries, can be called from and C++
programs, can integrate with Java
and .NET components
Python supports procedure-oriented programming as well as
object-oriented programming.
Supports different Programming Paradigm
Object
Oriented
Procedure
Oriented
C/C++ Extensible
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Zen of Python
C/C++
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Installation Steps
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Python Installation
Go to www.python.org1
Under Downloads tab,
select the latest Python
version for Windows
2
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Open the installer and click on Run3
Python Installation
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
4 Select ‘Add Python 3.6 to PATH’
5 Click on Install Now
Python Installation
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
6 Start IDLE which is a Python GUI & start scripting
Python Installation
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
C/C++
IDLE stands for integrated
Development and Learning
Environment
Python Installation
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Operators in Python
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Bitwise Operators
Identity Operators
Special Operators
Operators in Python
1
2
3
4
5
6
7
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Arithmetic Operators
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Bitwise Operators
Identity Operators
Special Operators
1
2
3
4
5
6
7
+
Add two operands or unary plus
-
Subtract two operands or unary subtract
*
Multiply two operands
/
Divide left operand with the right and result
is in float
>> 2 + 3
5
>> +2
>> 3 – 1
2
>> -2
>> 2 * 3
6
>> 6 / 3
2.0
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Arithmetic Operators
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Bitwise Operators
Identity Operators
Special Operators
1
2
3
4
5
6
7
**
Left operand raised to the power of right
% Remainder of the division of left operand
by the right
// division that results into whole number
adjusted to the left in the number line
>> 2 + 3
5
>> +2
>> 3 – 1
2
>> -2
>> 2 * 3
6
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Assignment Operators
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Assignment Operators
Comparison Operators
Logical Operators
Bitwise Operators
Identity Operators
Arithmetic Operators1
Assignment Operators2
3
4
5
6
Special Operators7
/=
x = x / <right operand>
%=
x = x % <right operand>
//=
x = x // <right operand>
**=
x = x ** <right operand>
>> x/=5
>> print(x)
1.0
>> x%=5
>> print(x)
0
>> x //= 2
>> print(x)
2
>> x**= 5
>> print(x)
32
>> x = 5
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Assignment Operators
Comparison Operators
Logical Operators
Bitwise Operators
Identity Operators
Arithmetic Operators1
Assignment Operators2
3
4
5
6
Special Operators7
&=
x = x & <right operand>
|=
x = x | <right operand>
^=
x = x ^ <right operand>
>>=
x = x >> <right operand>
>> x&=2
>> print(x)
0
>> x|=2
>> print(x)
>> 7
>> x ^= 2
>> print(x)
7
>> x >>=
2
>> print(x)
1
>> x = 5
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Comparison Operators
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Comparison Operators
Logical Operators
Bitwise Operators
Identity Operators
Arithmetic Operators1
Assignment Operators2
Comparison Operators3
4
5
6
Special Operators7
>
True if left operand is greater than the right
<
True if left operand is less than the right
==
True if left operand is equal to right
!=
True if left operand is not equal to the right
>> 2 > 3
False
>> 2 < 3
True
>>2 == 2
True
>> x >>=
2
>>print(x)
1
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Logical Operators
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Logical Operators
Bitwise Operators
Identity Operators
Arithmetic Operators1
Assignment Operators2
Comparison Operators3
Logical Operators4
5
6
Special Operators7
and
Returns x if x is False , y otherwise
or
Returns y if x is False, x otherwise
not
Returns True if x is True, False otherwise
>> 2 and
3
3
>> 2 or 3
2
>> not 1
False
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Bitwise Operators
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Bitwise Operators
Identity Operators
Arithmetic Operators1
Assignment Operators2
Comparison Operators3
Logical Operators4
Bitwise Operators5
6
Membership Operators7
a | b
Perform OR operation on each bit of the no.
a & b Perform AND operation on each bit of the
number
a ^ b Perform XOR operation on each bit of
the number
111 7
101 5
111 7
111 7
101 5
111 5
111 7
101 5
111 2
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Bitwise Operators
Identity Operators
Arithmetic Operators1
Assignment Operators2
Comparison Operators3
Logical Operators4
6
Membership Operators7
a >> b
Shift a right by b bits
a << b
Shift a left by b bits
3 >> 2 = 0
0011 0000
3 << 2 = 12
0011 1100Bitwise Operators5
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Identity Operators
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Identity Operators
Arithmetic Operators1
Assignment Operators2
Comparison Operators3
Logical Operators4
Bitwise Operators5
Identity Operators6
Membership Operators7
is
True if the operands are identical (refer to
the same object)
is not True if the operands are not identical (do
not refer to the same object)
>> x = 5
>> x is 5
True
>> x = 5
>> x is not 5
False
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Membership Operators
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Membership Operators
Arithmetic Operators1
Assignment Operators2
Comparison Operators3
Logical Operators4
Bitwise Operators5
Identity Operators6
Membership Operators7
is
True if the operands are identical (refer to the
same object)
is not True if the operands are not identical (do not
refer to the same object)
>> 3 in x
True
>> 3 not in x
False
X = [1, 2, 3, 4, 5]
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatypes
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
C/C++
➢ No need to declare variables before using them
➢ Python is a loosely typed language. Therefore, no need to define the datatype of variables
Datatype
Numbers Strings Tuples Lists Dictionaries Sets
Immutable Mutable
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
➢ Strings are sequences of one-character strings
Example:
sample = ‘Welcome to Python Tutorial’
or
sample = “Welcome to Python Tutorial”
➢ Multi-line strings can be denoted using triple quotes, ''' or ""“
Example:
sample = “””Don’t Go Gentle into the good Night
Rage! Rage, against the dying light”””
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
Sequence Operations:
➢ Concatenation:
➢ Repetition
➢ Slicing
➢ Indexing
‘Python’ ‘Tutorial’ ‘Edureka Tutorial’
‘Edureka’ 2 ‘EdurekaEdureka’
**
string1 = ‘Edureka’ string1[2:7] ‘ureka’
string1 = ‘Edureka’ string1[-1] + string[1] ‘da’
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
Type Specific Method:
➢ find():
➢ replace()
➢ split()
➢ count()
str = ‘Edureka’ str.find ( ‘ureka’ ) ‘ureka’
str = ‘Edureka’ str.replace ( ‘Ed’,’E’ ) ‘Eureka’
str = ‘E, d, u, r, e, k, a’ s.split ( ‘,’ )
[‘E’, ‘d’, ‘u’, ‘r’, ‘e’, ‘k’,
‘a’]
str = ‘Edureka’ str.count(‘e’, beg=2, end=6) 2
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
Type Specific Method:
➢ upper():
➢ max()
➢ min()
➢ isalpha()
str = ‘edureka’ str.upper () ‘EDUREKA’
str = ‘Edureka’ max (str) ‘u’
min ( str ) ‘a’
str = ‘Edureka’
str = ‘Edureka’
str.isalpha() True
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable ➢ A tuple is a sequence of immutable Python objects like floating number, string
literals, etc.
➢ The tuples can’t be changed unlike lists
➢ Tuples are defined using curve braces
myTuple = ( ‘Edureka’ , 2.4, 5, ‘Python’ )
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
Sequence Operations:
➢ Concatenation:
➢ Repetition
➢ Slicing
➢ Indexing
tup = ( ‘a’ , ‘b’ , ‘c’ ) tup +( ‘d’ ) ( ‘a’ , ‘b’ , ‘c’ , ‘d’ )
tup = ( ‘a’ , ‘b’ , ‘c’ ) tup[1:2] ( ‘b’ , ‘c’ )
tup = ( ‘a’ , ‘b’ , ‘c’ ) tup[0] ‘a’
tup = ( ‘a’ , ‘b’ , ‘c’ ) tup * 2 (‘a’ , ‘b’ , ‘c’ , ‘a’ , ‘b’ ,
‘c’ )
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable ➢ A list is a sequence of mutable Python objects like floating number, string literals,
etc.
➢ The lists can be modified
➢ Tuples are defined using square braces
myList = [ ‘Edureka’ , 2.4, 5, ‘Python’ ]
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
Sequence Operations:
➢ Concatenation:
➢ Repetition
➢ Slicing
➢ Indexing
[ ‘1’ , ‘b’ , 2.5 ] ‘d’ [ 1 , ‘b’ , 2.5 , ‘d’ ]
[ ‘a’ , ‘b’ , 2.5 ] 2 [‘a’ , ‘b’ , ‘a’ , ‘b’ ]
**
list = [‘a’ , ‘b’ , ‘c’ ,’d’] list[1:3] ( ‘b’ , ‘c’, ‘d’ )
list = [‘a’ , ‘b’ , ‘c’] list[0] ‘a’
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
Type Specific Method
➢ append(value)
➢ extend(list)
➢ insert(index, value)
➢ pop()
list = [1, ‘a’, 2.5] List.append (‘d’ ) [ 1 , ‘a’ , 2.5 , ‘d’ ]
list = [1, ‘a’, 2.5] list.extend ( [‘c’, ‘d’] ) [1 , ‘a’ , 2.5 , ‘c’, ‘d’]
list = [1, ‘a’, 2.5] List.insert(2,’b’) [1, ’a’, ‘b’ , 2.5 ]
list = [‘a’ , ‘b’ , ‘c’] List.pop() [ ‘a’, ‘b’ ]
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
➢ Dictionaries are perhaps the most flexible built-in data type in Python
➢ Dictionaries, items are stored and fetched by key, instead of by positional
offset
Key
Value
myDict = { 1: ‘Josh’ , 2: ‘Bob’, 3: ‘James’ }
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
➢ empty dictionary
➢ dictionary with integer keys
➢ dictionary with mixed keys
➢ from sequence having each item as a pair
myDict = {}
myDict = {1: 'apple', 2: 'ball'}
myDict = {'name': 'John', 1: [2, 4, 3]}
myDict = dict([(1,'apple'), (2,'ball')])
Dictionary Examples
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
➢ Accessing Dictionary
➢ len()
➢ key()
➢ values()
myDict = {1: 'apple', 2: 'ball'}
myDict = {1: 'apple', 2: 'ball'} myDict [1] ‘apple’
len(myDict) 2
myDict = {1: 'apple', 2: 'ball'} myDict.key() [1, 2]
myDict = {1: 'apple', 2: 'ball'} myDict.values() [‘apple’, ‘ball’]
Dictionary Methods
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
➢ items()
➢ get()
➢ update()
➢ pop()
myDict = {1: 'apple', 2: 'ball'}
myDict = {1: 'apple', 2: 'ball'} myDict.items() [(1, ‘apple’), (2, ball)]
myDict.get(1) ‘apple’
myDict = {1: ‘a', 2: ‘b'} myDict.update(3: ’c’) {1: ’a’, 2: ‘b’, 3: ‘c’}
myDict = {1: 'apple', 2: 'ball'} myDict. pop(2) {1: ‘apple’}
Dictionary Methods
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
➢ A set is an unordered collection of items
➢ Every element is unique (no duplicates) and must be immutable (which cannot
be changed)
mySet = {1, 2, 3}
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Datatype
Tuples
Numbers
Strings
Lists
Dictionaries
Sets
Mutable
Immutable
Sets Methods
➢ Creating set
➢ Union
➢ intersection
➢ difference
myS1 = {1, 2, ‘c’}
myS2 = {1, ‘b’, ‘c’}
mySet = {1, 2, 3, 3} {1, 2, 3}
myS1 | myS2 {1, 2, ‘c’, ‘b’}
myS1 = {1, 2, ‘c’}
myS2 = {1, ‘b’, c’’}
myS1 & myS2 {1, ‘c’}
myS1 = {1, 2, ‘c’}
myS2 = {1, b’’, ‘c’}
myS1 - myS2 { 2 }
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Flow Control
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Flow Control
If.. else..
while
If… elif…
else
for
if
break
continue
Flow
Control
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Flow Control
Syntax:
if (condition):
statements 1 …
else:
statements 2 …
CHECK
CONDITION
EXECUTE BLOCK 1
EXECUTE BLOCK 2
START
1. If statement
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
CHECK
CONDITION 1
Flow Control
2. if… elif…else statement
CHECK
CONDITION 1
EXECUTE BLOCK 1
EXECUTE BLOCK 2
START
Syntax:
if (condition 1):
statements 1 …
elif (condition 2):
statements 2 …
else
statements 3 … EXECUTE BLOCK 3
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Flow Control
LOOPS REPEAT ACTIONS
SO YOU DON’T HAVE TO ...
For
While
Repeat things until the
loop condition is true
Repeat things till the
given number of times
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Flow Control
3. while statement
CHECK
CONDITION 1
EXECUTE BLOCK 1
START
Syntax:
while (condition is True):
statements1…
repeat
EXIT LOOP
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Flow Control
4. for statement
check if
Count < 10
Count = 0
START
Syntax:
for iterator name in iterating sequence:
execute statements…
Add 1 to Count
Execute Statements
Exit loop
repeat
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Flow Control
Syntax:
break Check Loop
Condition
START
repeat
EXIT LOOP
Check Break
Condition
EXIT LOOP
Execute Block
5. for statement
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Flow Control
6. continue
Syntax:
continue
Check Loop
Condition
START
repeat
EXIT LOOP
Check Continue
Condition
Skip Next
Statement
Execute Block
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Functions in Python
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Function
A function is a block of organized, reusable sets of instructions that is used
to perform some related actions.
Why do we use functions?
➢ Re – usability of code minimizes redundancy
➢ Procedural decomposition makes things organized
Function
Built-in
Function
User Defined
Function
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Function
User Defined Function
Syntax:
def func_name (arg1, arg2, arg3, ….):
statements…
return [expression]
Example:
def add ( a, b )
sum = a + b
return sum
adding two number
defining function
Input variable
print variable
output
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Function – Pass By Reference
Call by Object Reference:
Python supports call by value where the value is always an object reference, not the value of the object
defining function
print the modified list
output
Modifying list
calling the function
both list are pointing to different
object reference
print the initial list
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Function
Call by Object Reference
defining function
print the list
output
appending elements to list
calling the function
both input_list & myList pointing
to same list object reference
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
File Handling in Python
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
File Handling & I/O Methods
A file or a computer file is a chunk
of logically related data or
information which can be used by
computer programs.
Search Quality
open ( filename, mode )
write( )
close( )
read( )
File Operations in Python
Opening a file
Reading a file
Writing a file
Closing a file
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
File Handling & I/O Methods
open file
write file
read file
close file
open in
Read + write
mode
output
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Summary
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Summary
What is Python? Python FeaturesWho uses Python?
Python Installation DatatypePython Operators
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Summary
Flow Control File HandlingFunctions
www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
Thank You…
Questions/Queries/Feedback

More Related Content

What's hot (20)

PDF
Variables & Data Types In Python | Edureka
Edureka!
 
PPTX
Introduction to python
Ayshwarya Baburam
 
PDF
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...
Edureka!
 
PDF
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Edureka!
 
PPTX
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
PDF
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
PPTX
Python | What is Python | History of Python | Python Tutorial
QA TrainingHub
 
PPT
Python ppt
Mohita Pandey
 
PDF
Python Basics
tusharpanda88
 
PDF
Introduction to python
Agung Wahyudi
 
PPTX
Python basics
Jyoti shukla
 
PPTX
Introduction to-python
Aakashdata
 
PPTX
Python basics
RANAALIMAJEEDRAJPUT
 
PPT
Introduction to python
Syed Zaid Irshad
 
PPTX
Intro to Python Programming Language
Dipankar Achinta
 
PDF
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
Edureka!
 
PDF
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Edureka!
 
PDF
Lesson 02 python keywords and identifiers
Nilimesh Halder
 
PPT
Introduction to Python
Nowell Strite
 
PDF
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Edureka!
 
Variables & Data Types In Python | Edureka
Edureka!
 
Introduction to python
Ayshwarya Baburam
 
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...
Edureka!
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Edureka!
 
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
Python | What is Python | History of Python | Python Tutorial
QA TrainingHub
 
Python ppt
Mohita Pandey
 
Python Basics
tusharpanda88
 
Introduction to python
Agung Wahyudi
 
Python basics
Jyoti shukla
 
Introduction to-python
Aakashdata
 
Python basics
RANAALIMAJEEDRAJPUT
 
Introduction to python
Syed Zaid Irshad
 
Intro to Python Programming Language
Dipankar Achinta
 
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
Edureka!
 
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Edureka!
 
Lesson 02 python keywords and identifiers
Nilimesh Halder
 
Introduction to Python
Nowell Strite
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Edureka!
 

Similar to Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka (20)

PDF
Python Programming | Python Programming For Beginners | Python Tutorial | Edu...
Edureka!
 
PPTX
Lecture 1 .
SwatiHans10
 
PPT
Py-Slides-2 (1).ppt
KalaiVani395886
 
PPT
Py-Slides-2.ppt
TejaValmiki
 
PPT
Py-Slides-2.ppt
AllanGuevarra1
 
PPT
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
PraveenaFppt
 
PPT
Python programming
saroja20
 
PPTX
Lecture 07.pptx
Mohammad Hassan
 
PPT
python operators.ppt
ErnieAcuna
 
PPTX
Welcome to python workshop
Mukul Kirti Verma
 
PPTX
Python_Haegl.powerpoint presentation. tx
vishwanathgoudapatil1
 
PPTX
Python assignment 1 Biswajit Mohapatra.pptx
BiswajitMohapatra59
 
PPTX
Operators in Python Arithmetic Operators
ramireddyobulakondar
 
PPTX
python operators.pptx
irsatanoli
 
PPTX
operatorsinpython-18112209560412 (1).pptx
urvashipundir04
 
PPTX
Python.pptx
Ankita Shirke
 
PPTX
Python Lec-6 Operatorguijjjjuugggggs.pptx
ks812227
 
PPTX
1. PGA2.0-Python Programming-Intro to Python.pptx
Rakesh Ahuja
 
PPTX
“Python” or “CPython” is written in C/C+
Mukeshpanigrahy1
 
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 5
FabMinds
 
Python Programming | Python Programming For Beginners | Python Tutorial | Edu...
Edureka!
 
Lecture 1 .
SwatiHans10
 
Py-Slides-2 (1).ppt
KalaiVani395886
 
Py-Slides-2.ppt
TejaValmiki
 
Py-Slides-2.ppt
AllanGuevarra1
 
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
PraveenaFppt
 
Python programming
saroja20
 
Lecture 07.pptx
Mohammad Hassan
 
python operators.ppt
ErnieAcuna
 
Welcome to python workshop
Mukul Kirti Verma
 
Python_Haegl.powerpoint presentation. tx
vishwanathgoudapatil1
 
Python assignment 1 Biswajit Mohapatra.pptx
BiswajitMohapatra59
 
Operators in Python Arithmetic Operators
ramireddyobulakondar
 
python operators.pptx
irsatanoli
 
operatorsinpython-18112209560412 (1).pptx
urvashipundir04
 
Python.pptx
Ankita Shirke
 
Python Lec-6 Operatorguijjjjuugggggs.pptx
ks812227
 
1. PGA2.0-Python Programming-Intro to Python.pptx
Rakesh Ahuja
 
“Python” or “CPython” is written in C/C+
Mukeshpanigrahy1
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
FabMinds
 
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
PDF
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
PDF
Tableau Tutorial for Data Science | Edureka
Edureka!
 
PDF
Top 5 PMP Certifications | Edureka
Edureka!
 
PDF
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
PDF
Linux Mint Tutorial | Edureka
Edureka!
 
PDF
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
PDF
Importance of Digital Marketing | Edureka
Edureka!
 
PDF
RPA in 2020 | Edureka
Edureka!
 
PDF
Email Notifications in Jenkins | Edureka
Edureka!
 
PDF
EA Algorithm in Machine Learning | Edureka
Edureka!
 
PDF
Cognitive AI Tutorial | Edureka
Edureka!
 
PDF
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
PDF
Blue Prism Top Interview Questions | Edureka
Edureka!
 
PDF
Big Data on AWS Tutorial | Edureka
Edureka!
 
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
PDF
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
PDF
Introduction to DevOps | Edureka
Edureka!
 
PDF
ITIL® Tutorial for Beginners | ITIL® Foundation Training | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Edureka!
 
ITIL® Tutorial for Beginners | ITIL® Foundation Training | Edureka
Edureka!
 
Ad

Recently uploaded (20)

PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 

Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka

  • 2. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Agenda ➢ Python Introduction ➢ Who uses Python? ➢ Python Features ➢ Operators in Python ➢ Datatypes in Python ➢ Flow Control ➢ Functions in Python ➢ File Handling in Python
  • 4. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Python Introduction ➢ Python is an interpreted, object-oriented, high-level programming language with dynamic semantics ➢ Python was created by Guido Rossum in 1989 and is very easy to learn Procedure Oriented Object Oriented Easy to Learn High Level Language
  • 6. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Who Uses Python? The popular YouTube video sharing service is largely written in Python. C O M P A N I E S U S I N G P Y T H O N Google makes extensive use of Python in its web search systems. The Raspberry Pi single- board computer promotes Python as its educational language. Dropbox storage service codes both its server and desktop client software primarily in Python. BitTorrent peer-to-peer file sharing system began its life as a Python program. NASA, Los Alamos, Fermilab, JPL, and others use Python for scientific programming tasks. The NSA uses Python for cryptography and intelligence analysis. Netflix and Yelp have both documented the role of Python in their software infrastructures.
  • 8. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Python Features Simple and Easy to Learn Free and Open Source Python is a simple and easy to learn, read & write Python is an example of a FLOSS (Free/Libre and Open Source Software) which means one can freely distribute copies of this software, read it's source code, modify it, etc.
  • 9. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Python Features High-level Language Portable One does not need to bother about the low-level details like memory allocation, etc. while writing Python script Supported by many platforms like Linux, Windows, FreeBSD, Macintosh, Solaris, OS/2, Amiga, AROS, AS/400, BeOS, OS/390, PlayStation, Windows CE, etc. a=3 b=5 sum=a+b print(sum) 01001010110110 11101100001101 10110101100101 0101011010 compile
  • 10. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Python Features Python code can invoke C and C++ libraries, can be called from and C++ programs, can integrate with Java and .NET components Python supports procedure-oriented programming as well as object-oriented programming. Supports different Programming Paradigm Object Oriented Procedure Oriented C/C++ Extensible
  • 13. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Python Installation Go to www.python.org1 Under Downloads tab, select the latest Python version for Windows 2
  • 14. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Open the installer and click on Run3 Python Installation
  • 15. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING 4 Select ‘Add Python 3.6 to PATH’ 5 Click on Install Now Python Installation
  • 16. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING 6 Start IDLE which is a Python GUI & start scripting Python Installation
  • 17. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING C/C++ IDLE stands for integrated Development and Learning Environment Python Installation
  • 19. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Arithmetic Operators Assignment Operators Comparison Operators Logical Operators Bitwise Operators Identity Operators Special Operators Operators in Python 1 2 3 4 5 6 7
  • 20. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Arithmetic Operators Arithmetic Operators Assignment Operators Comparison Operators Logical Operators Bitwise Operators Identity Operators Special Operators 1 2 3 4 5 6 7 + Add two operands or unary plus - Subtract two operands or unary subtract * Multiply two operands / Divide left operand with the right and result is in float >> 2 + 3 5 >> +2 >> 3 – 1 2 >> -2 >> 2 * 3 6 >> 6 / 3 2.0
  • 21. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Arithmetic Operators Arithmetic Operators Assignment Operators Comparison Operators Logical Operators Bitwise Operators Identity Operators Special Operators 1 2 3 4 5 6 7 ** Left operand raised to the power of right % Remainder of the division of left operand by the right // division that results into whole number adjusted to the left in the number line >> 2 + 3 5 >> +2 >> 3 – 1 2 >> -2 >> 2 * 3 6
  • 22. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Assignment Operators
  • 23. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Assignment Operators Comparison Operators Logical Operators Bitwise Operators Identity Operators Arithmetic Operators1 Assignment Operators2 3 4 5 6 Special Operators7 /= x = x / <right operand> %= x = x % <right operand> //= x = x // <right operand> **= x = x ** <right operand> >> x/=5 >> print(x) 1.0 >> x%=5 >> print(x) 0 >> x //= 2 >> print(x) 2 >> x**= 5 >> print(x) 32 >> x = 5
  • 24. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Assignment Operators Comparison Operators Logical Operators Bitwise Operators Identity Operators Arithmetic Operators1 Assignment Operators2 3 4 5 6 Special Operators7 &= x = x & <right operand> |= x = x | <right operand> ^= x = x ^ <right operand> >>= x = x >> <right operand> >> x&=2 >> print(x) 0 >> x|=2 >> print(x) >> 7 >> x ^= 2 >> print(x) 7 >> x >>= 2 >> print(x) 1 >> x = 5
  • 25. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Comparison Operators
  • 26. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Comparison Operators Logical Operators Bitwise Operators Identity Operators Arithmetic Operators1 Assignment Operators2 Comparison Operators3 4 5 6 Special Operators7 > True if left operand is greater than the right < True if left operand is less than the right == True if left operand is equal to right != True if left operand is not equal to the right >> 2 > 3 False >> 2 < 3 True >>2 == 2 True >> x >>= 2 >>print(x) 1
  • 28. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Logical Operators Bitwise Operators Identity Operators Arithmetic Operators1 Assignment Operators2 Comparison Operators3 Logical Operators4 5 6 Special Operators7 and Returns x if x is False , y otherwise or Returns y if x is False, x otherwise not Returns True if x is True, False otherwise >> 2 and 3 3 >> 2 or 3 2 >> not 1 False
  • 30. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Bitwise Operators Identity Operators Arithmetic Operators1 Assignment Operators2 Comparison Operators3 Logical Operators4 Bitwise Operators5 6 Membership Operators7 a | b Perform OR operation on each bit of the no. a & b Perform AND operation on each bit of the number a ^ b Perform XOR operation on each bit of the number 111 7 101 5 111 7 111 7 101 5 111 5 111 7 101 5 111 2
  • 31. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Bitwise Operators Identity Operators Arithmetic Operators1 Assignment Operators2 Comparison Operators3 Logical Operators4 6 Membership Operators7 a >> b Shift a right by b bits a << b Shift a left by b bits 3 >> 2 = 0 0011 0000 3 << 2 = 12 0011 1100Bitwise Operators5
  • 33. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Identity Operators Arithmetic Operators1 Assignment Operators2 Comparison Operators3 Logical Operators4 Bitwise Operators5 Identity Operators6 Membership Operators7 is True if the operands are identical (refer to the same object) is not True if the operands are not identical (do not refer to the same object) >> x = 5 >> x is 5 True >> x = 5 >> x is not 5 False
  • 34. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Membership Operators
  • 35. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Membership Operators Arithmetic Operators1 Assignment Operators2 Comparison Operators3 Logical Operators4 Bitwise Operators5 Identity Operators6 Membership Operators7 is True if the operands are identical (refer to the same object) is not True if the operands are not identical (do not refer to the same object) >> 3 in x True >> 3 not in x False X = [1, 2, 3, 4, 5]
  • 37. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype C/C++ ➢ No need to declare variables before using them ➢ Python is a loosely typed language. Therefore, no need to define the datatype of variables Datatype Numbers Strings Tuples Lists Dictionaries Sets Immutable Mutable
  • 38. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable
  • 39. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable ➢ Strings are sequences of one-character strings Example: sample = ‘Welcome to Python Tutorial’ or sample = “Welcome to Python Tutorial” ➢ Multi-line strings can be denoted using triple quotes, ''' or ""“ Example: sample = “””Don’t Go Gentle into the good Night Rage! Rage, against the dying light”””
  • 40. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable Sequence Operations: ➢ Concatenation: ➢ Repetition ➢ Slicing ➢ Indexing ‘Python’ ‘Tutorial’ ‘Edureka Tutorial’ ‘Edureka’ 2 ‘EdurekaEdureka’ ** string1 = ‘Edureka’ string1[2:7] ‘ureka’ string1 = ‘Edureka’ string1[-1] + string[1] ‘da’
  • 41. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable Type Specific Method: ➢ find(): ➢ replace() ➢ split() ➢ count() str = ‘Edureka’ str.find ( ‘ureka’ ) ‘ureka’ str = ‘Edureka’ str.replace ( ‘Ed’,’E’ ) ‘Eureka’ str = ‘E, d, u, r, e, k, a’ s.split ( ‘,’ ) [‘E’, ‘d’, ‘u’, ‘r’, ‘e’, ‘k’, ‘a’] str = ‘Edureka’ str.count(‘e’, beg=2, end=6) 2
  • 42. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable Type Specific Method: ➢ upper(): ➢ max() ➢ min() ➢ isalpha() str = ‘edureka’ str.upper () ‘EDUREKA’ str = ‘Edureka’ max (str) ‘u’ min ( str ) ‘a’ str = ‘Edureka’ str = ‘Edureka’ str.isalpha() True
  • 43. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable ➢ A tuple is a sequence of immutable Python objects like floating number, string literals, etc. ➢ The tuples can’t be changed unlike lists ➢ Tuples are defined using curve braces myTuple = ( ‘Edureka’ , 2.4, 5, ‘Python’ )
  • 44. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable Sequence Operations: ➢ Concatenation: ➢ Repetition ➢ Slicing ➢ Indexing tup = ( ‘a’ , ‘b’ , ‘c’ ) tup +( ‘d’ ) ( ‘a’ , ‘b’ , ‘c’ , ‘d’ ) tup = ( ‘a’ , ‘b’ , ‘c’ ) tup[1:2] ( ‘b’ , ‘c’ ) tup = ( ‘a’ , ‘b’ , ‘c’ ) tup[0] ‘a’ tup = ( ‘a’ , ‘b’ , ‘c’ ) tup * 2 (‘a’ , ‘b’ , ‘c’ , ‘a’ , ‘b’ , ‘c’ )
  • 45. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable ➢ A list is a sequence of mutable Python objects like floating number, string literals, etc. ➢ The lists can be modified ➢ Tuples are defined using square braces myList = [ ‘Edureka’ , 2.4, 5, ‘Python’ ]
  • 46. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable Sequence Operations: ➢ Concatenation: ➢ Repetition ➢ Slicing ➢ Indexing [ ‘1’ , ‘b’ , 2.5 ] ‘d’ [ 1 , ‘b’ , 2.5 , ‘d’ ] [ ‘a’ , ‘b’ , 2.5 ] 2 [‘a’ , ‘b’ , ‘a’ , ‘b’ ] ** list = [‘a’ , ‘b’ , ‘c’ ,’d’] list[1:3] ( ‘b’ , ‘c’, ‘d’ ) list = [‘a’ , ‘b’ , ‘c’] list[0] ‘a’
  • 47. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable Type Specific Method ➢ append(value) ➢ extend(list) ➢ insert(index, value) ➢ pop() list = [1, ‘a’, 2.5] List.append (‘d’ ) [ 1 , ‘a’ , 2.5 , ‘d’ ] list = [1, ‘a’, 2.5] list.extend ( [‘c’, ‘d’] ) [1 , ‘a’ , 2.5 , ‘c’, ‘d’] list = [1, ‘a’, 2.5] List.insert(2,’b’) [1, ’a’, ‘b’ , 2.5 ] list = [‘a’ , ‘b’ , ‘c’] List.pop() [ ‘a’, ‘b’ ]
  • 48. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable ➢ Dictionaries are perhaps the most flexible built-in data type in Python ➢ Dictionaries, items are stored and fetched by key, instead of by positional offset Key Value myDict = { 1: ‘Josh’ , 2: ‘Bob’, 3: ‘James’ }
  • 49. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable ➢ empty dictionary ➢ dictionary with integer keys ➢ dictionary with mixed keys ➢ from sequence having each item as a pair myDict = {} myDict = {1: 'apple', 2: 'ball'} myDict = {'name': 'John', 1: [2, 4, 3]} myDict = dict([(1,'apple'), (2,'ball')]) Dictionary Examples
  • 50. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable ➢ Accessing Dictionary ➢ len() ➢ key() ➢ values() myDict = {1: 'apple', 2: 'ball'} myDict = {1: 'apple', 2: 'ball'} myDict [1] ‘apple’ len(myDict) 2 myDict = {1: 'apple', 2: 'ball'} myDict.key() [1, 2] myDict = {1: 'apple', 2: 'ball'} myDict.values() [‘apple’, ‘ball’] Dictionary Methods
  • 51. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable ➢ items() ➢ get() ➢ update() ➢ pop() myDict = {1: 'apple', 2: 'ball'} myDict = {1: 'apple', 2: 'ball'} myDict.items() [(1, ‘apple’), (2, ball)] myDict.get(1) ‘apple’ myDict = {1: ‘a', 2: ‘b'} myDict.update(3: ’c’) {1: ’a’, 2: ‘b’, 3: ‘c’} myDict = {1: 'apple', 2: 'ball'} myDict. pop(2) {1: ‘apple’} Dictionary Methods
  • 52. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable ➢ A set is an unordered collection of items ➢ Every element is unique (no duplicates) and must be immutable (which cannot be changed) mySet = {1, 2, 3}
  • 53. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Datatype Tuples Numbers Strings Lists Dictionaries Sets Mutable Immutable Sets Methods ➢ Creating set ➢ Union ➢ intersection ➢ difference myS1 = {1, 2, ‘c’} myS2 = {1, ‘b’, ‘c’} mySet = {1, 2, 3, 3} {1, 2, 3} myS1 | myS2 {1, 2, ‘c’, ‘b’} myS1 = {1, 2, ‘c’} myS2 = {1, ‘b’, c’’} myS1 & myS2 {1, ‘c’} myS1 = {1, 2, ‘c’} myS2 = {1, b’’, ‘c’} myS1 - myS2 { 2 }
  • 55. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Flow Control If.. else.. while If… elif… else for if break continue Flow Control
  • 56. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Flow Control Syntax: if (condition): statements 1 … else: statements 2 … CHECK CONDITION EXECUTE BLOCK 1 EXECUTE BLOCK 2 START 1. If statement
  • 57. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING CHECK CONDITION 1 Flow Control 2. if… elif…else statement CHECK CONDITION 1 EXECUTE BLOCK 1 EXECUTE BLOCK 2 START Syntax: if (condition 1): statements 1 … elif (condition 2): statements 2 … else statements 3 … EXECUTE BLOCK 3
  • 58. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Flow Control LOOPS REPEAT ACTIONS SO YOU DON’T HAVE TO ... For While Repeat things until the loop condition is true Repeat things till the given number of times
  • 59. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Flow Control 3. while statement CHECK CONDITION 1 EXECUTE BLOCK 1 START Syntax: while (condition is True): statements1… repeat EXIT LOOP
  • 60. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Flow Control 4. for statement check if Count < 10 Count = 0 START Syntax: for iterator name in iterating sequence: execute statements… Add 1 to Count Execute Statements Exit loop repeat
  • 61. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Flow Control Syntax: break Check Loop Condition START repeat EXIT LOOP Check Break Condition EXIT LOOP Execute Block 5. for statement
  • 62. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Flow Control 6. continue Syntax: continue Check Loop Condition START repeat EXIT LOOP Check Continue Condition Skip Next Statement Execute Block
  • 64. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Function A function is a block of organized, reusable sets of instructions that is used to perform some related actions. Why do we use functions? ➢ Re – usability of code minimizes redundancy ➢ Procedural decomposition makes things organized Function Built-in Function User Defined Function
  • 65. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Function User Defined Function Syntax: def func_name (arg1, arg2, arg3, ….): statements… return [expression] Example: def add ( a, b ) sum = a + b return sum adding two number defining function Input variable print variable output
  • 66. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Function – Pass By Reference Call by Object Reference: Python supports call by value where the value is always an object reference, not the value of the object defining function print the modified list output Modifying list calling the function both list are pointing to different object reference print the initial list
  • 67. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Function Call by Object Reference defining function print the list output appending elements to list calling the function both input_list & myList pointing to same list object reference
  • 68. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING File Handling in Python
  • 69. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING File Handling & I/O Methods A file or a computer file is a chunk of logically related data or information which can be used by computer programs. Search Quality open ( filename, mode ) write( ) close( ) read( ) File Operations in Python Opening a file Reading a file Writing a file Closing a file
  • 70. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING File Handling & I/O Methods open file write file read file close file open in Read + write mode output
  • 72. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Summary What is Python? Python FeaturesWho uses Python? Python Installation DatatypePython Operators
  • 73. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Summary Flow Control File HandlingFunctions
  • 74. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING Thank You… Questions/Queries/Feedback