Python is a programming language created by Guido van Rossum in 1991. It is easy to learn, platform independent, and has a simple syntax. Python can be used for tasks like building websites, developing games, scientific computation, and artificial intelligence. Some key features of Python include being interpreted, having dynamic typing, and being open source. Common data types in Python include numbers, strings, lists, tuples, dictionaries, and sets. Python supports operators for arithmetic, comparison, logical, bitwise, and identity operations. Control flow statements like if/else, for loops, and while loops allow for conditionally executing blocks of code.
2. Introduction to Python
Python is a simple programming language used to
write codes for the computer programs.
Python was created by Guido Van Rossum when he
was working at CWI( Centrum Wiskunde &
Informatica), which is a National research institute
for mathematics and computer science in
Netherland.
The language was release in 1991.
Python is a high level programing language.
verma.sameeksha90@gmail.com
2
3. FEATURES OF PYTHON
It is an easy to learn general purpose programing
language.
It is a platform independent programing language,
which means it can be used on any machine and in
any operating system.
It has a simple syntax
Python is a case sensitive language.
It is an interrupted language.
It is free to use and even free for commercial product.
verma.sameeksha90@gmail.com 3
4. APPLICATIONS OF PYTHON
PROGRAMING
Build a website
Develop games
Program robot
Perform scientific computation
Develop artificial intelligence application
verma.sameeksha90@gmail.com 4
5. WHY LEARN PYTHON
It cuts development time with its simple to
read syntax and easy compilation features.
Debugging your program is a breeze in python
with its built in debugger
Python makes programmers more productive
Python runs on windows Linux/Unix, Mac OS
and has been ported to JAVA and .NET virtual
machines.
verma.sameeksha90@gmail.com 5
6. Python has evolved as the most
preferred language for Data
Analytics and the increasing search
trends on Python also indicates that
Python is the next ‘Big Thing’ and
most for professionals in the Data
Analytics Domain.
verma.sameeksha90@gmail.com 6
9. Arithmetic Operators
Add two operands
>>2+3
5
Subtract two operands
>>5-1
4
Multiply two operands
>>2*3
6
Divide left operand with
right and result in float.
>>6/3
2.0
verma.sameeksha90@gmail.com 9
+
-
*
/
13. Comparison Operators
>
True if left operand is
greater than the right
>>2 > 3
False
<
True if left operand is less
than the right
>>2 < 3
True
==
True if left operand is
equal to right
>>2 == 3
False
!=
True if left operand is not
equal to the right
>> x!= 3
True
verma.sameeksha90@gmail.com 13
15. Logical Operators
And
Returns x if x is False , y otherwise
>> 2 and 3
3
or
Returns y if x is False , x otherwise
>> 2 or 3
2
not
Returns True if x is True , False otherwise
>> not 1
False
verma.sameeksha90@gmail.com 15
16. Bitwise Operators
a| b
Perform OR operation on
each bit of the number
111 7
101 5
111 7
a & b
Perform AND operation on
each bit of the number
111 7
101 5
101 5
a ^ b
Perform XOR operation on
each bit of the number
111 7
101 5
010 2
a>>b
shift a right by b bits
3>>2 = 0
0011 0000
a<<b
shift a left by b bits
3<<2 = 12
0011 1100
verma.sameeksha90@gmail.com 16
18. Identity Operators
is
True if the operands are identical (refer to the same
object)
>> x = 5
>> x is 5
True
is not
True if the operands are not identical (do not refer to the
same object)
>> x = 5
>> x is not 5
False
verma.sameeksha90@gmail.com 18
19. Membership Operators
x = [ 1,2,3,4,5]
In
True if it finds elements in the specified sequence
>> 3 in x
True
Not in
True if it does not finds elements in the specified
sequence
>> 3 not in x
False
verma.sameeksha90@gmail.com 19
21. DATATYPE
Python is a loosely typed language. Therefore, no need
to define the datatype of variables.
No need to declare variables before using them.
verma.sameeksha90@gmail.com 21
23. Datatype
Immutable
Numbers
STRINGS
Tuples
Mutable
Lists
Dictionaries
Sets
Strings are sequence of one-
character strings
Example:
1. Sample = “Welcome to python
Tutorial”
2. Sample = ‘Welcome to python
Tutorial’
Multi-line strings can be denoted
using triple quotes, “’ or “””
Example:
1. Sample = “”” It will help you lean
Python fundamentals with
examples in detail.”””
verma.sameeksha90@gmail.com 23
28. DATATYPE
Immutable
Numbers
Strings
TUPLES
Mutable
Lists
Dictionaries
Sets
A tupples 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.
verma.sameeksha90@gmail.com 28
31. DATATYPE
Immutable
Numbers
Strings
Tuples
Mutable
LISTS
Dictionaries
Sets
A lists is a sequence of mutable
Python objects like floating
number, string literals, etc.
The lists can be modified.
Tuples are defined using square
braces.
verma.sameeksha90@gmail.com 31
34. DATATYPE
Immutable
Numbers
Strings
Tuples
Mutable
Lists
DICTIONARIES
Sets
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.
verma.sameeksha90@gmail.com 34
35. Dictionary Examples
Empty dictionary
myDict={}
Dictionary with integer keys
myDict = {1:’apple’,2:’ball’}
Dictionary with mixed keys
myDict = {‘name’:’John’, 1:[2,4,3]}
From sequence having each item as a pair
myDict = dict([(1,’apple’),(2,’ball’)])
verma.sameeksha90@gmail.com 35
55. 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
verma.sameeksha90@gmail.com 55
56. USER DEFINED FUNCTION
SYNTAX:
def func_name(arg1,arg2,arg3,…):
Statements…
return [expression]
Example:
def add(a,b)
Sum = a+b
return sum
verma.sameeksha90@gmail.com 56
57. Abs()
The abs function returns the absolute value of the specified number.
Syntax abs(x)
Example x=abs(3+5j)
All()
verma.sameeksha90@gmail.com 57