2. About Me
Porimol Chandro
CSE 32 D
World University of Bangladesh(WUB)
Software Engineer,
Sohoz Technology Ltd.(STL)
FB : fb.com/porimol.chandro
Github : github.com/porimol
Email : p.c_roy@yahoo.com
3. Overview
● Background
● Syntax
● Data Types
● Operators
● Control Flow
● Functions
● OOP
● Modules/Packages
● Applications of Python
● Learning Resources
6. What is Python?
● Interpreted
● High Level Programming Language
● Multi-purpose
● Object Oriented
● Dynamic Typed
● Focus on Readability and Productivity
7. Features
● Easy to Learn
● Easy to Read
● Cross Platform
● Everything is an Object
● Interactive Shell
● A Broad Standard Library
8. Who Uses Python?
● Google
● Facebook
● Microsoft
● NASA
● PBS
● ...the list goes on...
9. Releases
● Created in 1989 by Guido Van Rossum
● Python 1.0 released in 1994
● Python 2.0 released in 2000
● Python released in 2008
● Python 3.x is the recommended version
15. Comments
# This is traditional one line comments
“This one is also one comment”
“““
If any string not assigned to a variable, then it is said to be multi-line
comments
This is the example of multi-line comments
”””
20. Strings
Single line
str_var = “World University of Bangladesh(WUB)”
Single line
str_var = ‘Computer Science & Engineering’
Multi-line
str_var = “““World University of Bangladesh (WUB) established under the private University Act, 1992 (amended in 1998),
approved and recognized by the Ministry of Education, Government of the People's Republic of Bangladesh and the University
Grants Commission (UGC) of Bangladesh is a leading university for utilitarian education.ucation.”””
Multi-line
str_var = ‘‘‘The University is governed by a board of trustees constituted as per private universities Act 2010 which is a non-
profit making concern.’’’
21. List
List in python known as a list of comma-separated
values or items between square brackets. A list
might be contain different types of items.
25. Dictionary
Another useful data type built into Python is the
dictionary. Dictionaries are sometimes found in
other programming languages as associative
memories or associative arrays.
26. Dictionary
Blank dictionary
dpt = {}
dpt = dict()
Set by key & get by key
dpt = {1: "CSE", 2: "CE", 3: "EEE"}
dpt[4] = “TE”
print(dpt[1])
Key value rules
A dictionary might be store any types of element but the key must be immutable.
For example:
marks = {"rakib" : 850, "porimol" : 200}
29. Arithmetic operators
Operator Meaning Example
+ Add two operands x+y
- Subtract right operand from the
left
x-y
* Multiply two operands x*y
/ Divide left operand by the right
one
X/y
% Modulus - remainder of the
division of left operand by the
right
X%y
// Floor division - division that
results into whole number
adjusted to the left in the number
line
X//y
** Exponent - left operand raised to
the power of right
x**y
30. Comparison operators
Operator Meaning Example
> Greater that - True if left operand
is greater than the right
x > y
< Less that - True if left operand is
less than the right
x < y
== Equal to - True if both operands
are equal
x == y
!= Not equal to - True if operands
are not equal
x != y
>= Greater than or equal to - True if
left operand is greater than or
equal to the right
x >= y
<= Less than or equal to - True if left
operand is less than or equal to
the right
x <= y
31. Logical operators
Operator Meaning Example
and True if both the operands are truex and y
or True if either of the operands is
true
x or y
not True if operand is false
(complements the operand)
not x
32. Bitwise operators
Operator Meaning Example
& Bitwise AND x& y = 0 (0000 0000)
| Bitwise OR x | y = 14 (0000 1110)
~ Bitwise NOT ~x = -11 (1111 0101)
^ Bitwise XOR x ^ y = 14 (0000 1110)
>> Bitwise right shift x>> 2 = 2 (0000 0010)
<< Bitwise left shift x<< 2 = 40 (0010 1000)
35. Conditions
if Statement
if 10 > 5:
print(“Yes, 10 is greater than 5”)
else Statement
if 10 > 5:
print(“Yes, 10 is greater than 5”)
else:
print(“Dhur, eita ki shunailen?”)
36. Loops
For Loop
for i in range(8) :
print(i)
Output
0
1
2
3
4
5
6
7
While Loop
i = 1
while i < 5 :
print(i)
i += 1
Output
1
2
3
4
5
39. Syntax of Function
Syntax:
def function_name(parameters):
“““docstring”””
statement(s)
Example:
def greet(name):
"""This function greets to the person passed in as parameter"""
print("Hello, " + name + ". Good morning!")
Function Call
greet(“Mr. Roy”)
42. Classes
Class is a blueprint for the object. A class creates a new local namespace
where all its attributes are defined. Attributes may be data or functions.
A simple class defining structure:
class MyNewClass:
'''This is a docstring. I have created a new class'''
pass
43. Class Example
class Vehicle:
# This is our first vehicle class
def color(self)
print(“Hello, I am color method from Vehicle class.”)
print(Vehicle.color)
Hello, I am color method from Vehicle class.
44. Objects
Object is simply a collection of data (variables) and methods (functions) that
act on those data.
Example of an Object:
obj = Vehicle()
47. Modules
● A module is a file containing Python definitions and statements. The file
name is the module name with the suffix .py appended.
● A module allows you to logically organize your Python code. Grouping
related code into a module makes the code easier to understand and use.
48. Packages
● Packages are a way of structuring Python’s module namespace by using
“dotted module names”.
● A package is a collection of Python modules: while a module is a single
Python file, a package is a directory of Python modules containing an
additional __init__.py file, to distinguish a package from a directory that just
happens to contain a bunch of Python scripts.
51. Applications
● Scientific and Numeric
● Web Application
● Mobile Application
● Cross Platform GUI
● Natural Language Processing
● Machine Learning
● Deep Learning
● Internet of Things
● ...the application goes on...