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
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Edureka!
 
PDF
Python Basics | Python Tutorial | Edureka
Edureka!
 
PDF
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Edureka!
 
PDF
Introduction To Python | Edureka
Edureka!
 
PPTX
Introduction to python
AnirudhaGaikwad4
 
PPTX
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
PDF
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Edureka!
 
PPT
Python ppt
Mohita Pandey
 
PDF
What is Python? | Edureka
Edureka!
 
PPTX
Python
Aashish Jain
 
PDF
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
PPTX
Introduction to-python
Aakashdata
 
PPT
Introduction to Python
Nowell Strite
 
PPTX
Python 3 Programming Language
Tahani Al-Manie
 
PPTX
Presentation on python
william john
 
PDF
Python introduction
Jignesh Kariya
 
PPTX
Beginning Python Programming
St. Petersburg College
 
PDF
Python programming
Prof. Dr. K. Adisesha
 
PDF
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Edureka!
 
PPTX
Python
SHIVAM VERMA
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Edureka!
 
Python Basics | Python Tutorial | Edureka
Edureka!
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Edureka!
 
Introduction To Python | Edureka
Edureka!
 
Introduction to python
AnirudhaGaikwad4
 
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Edureka!
 
Python ppt
Mohita Pandey
 
What is Python? | Edureka
Edureka!
 
Python
Aashish Jain
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
Introduction to-python
Aakashdata
 
Introduction to Python
Nowell Strite
 
Python 3 Programming Language
Tahani Al-Manie
 
Presentation on python
william john
 
Python introduction
Jignesh Kariya
 
Beginning Python Programming
St. Petersburg College
 
Python programming
Prof. Dr. K. Adisesha
 
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Edureka!
 
Python
SHIVAM VERMA
 

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

PPTX
Python_Haegl.powerpoint presentation. tx
vishwanathgoudapatil1
 
PPTX
Welcome to python workshop
Mukul Kirti Verma
 
PPTX
Advance Python programming languages-Simple Easy learning
sherinjoyson
 
PDF
Getting started with Python
Gaurav Gahlot
 
PDF
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Edureka!
 
PDF
Python Developer Certification
Vskills
 
PPTX
Python assignment 1 Biswajit Mohapatra.pptx
BiswajitMohapatra59
 
PPT
Python programming
saroja20
 
PPTX
Python_ppt for basics of python in details
Mukul Kirti Verma
 
PDF
Tips and tricks for data science projects with Python
Jose Manuel Ortega Candel
 
PDF
Reinforcement Learning Tutorial | Edureka
Edureka!
 
PDF
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
PDF
Cluj.py Meetup: Extending Python in C
Steffen Wenz
 
ODP
Intro To Spring Python
gturnquist
 
PDF
Python Web Development Tutorial | Web Development Using Django | Edureka
Edureka!
 
PDF
Python
Edureka!
 
PPTX
Python
Suman Chandra
 
PDF
Why is Python slow? Python Nordeste 2013
Daker Fernandes
 
PDF
Making the most of your Test Suite
ericholscher
 
Python_Haegl.powerpoint presentation. tx
vishwanathgoudapatil1
 
Welcome to python workshop
Mukul Kirti Verma
 
Advance Python programming languages-Simple Easy learning
sherinjoyson
 
Getting started with Python
Gaurav Gahlot
 
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Edureka!
 
Python Developer Certification
Vskills
 
Python assignment 1 Biswajit Mohapatra.pptx
BiswajitMohapatra59
 
Python programming
saroja20
 
Python_ppt for basics of python in details
Mukul Kirti Verma
 
Tips and tricks for data science projects with Python
Jose Manuel Ortega Candel
 
Reinforcement Learning Tutorial | Edureka
Edureka!
 
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
Cluj.py Meetup: Extending Python in C
Steffen Wenz
 
Intro To Spring Python
gturnquist
 
Python Web Development Tutorial | Web Development Using Django | Edureka
Edureka!
 
Python
Edureka!
 
Why is Python slow? Python Nordeste 2013
Daker Fernandes
 
Making the most of your Test Suite
ericholscher
 
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
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 

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