SlideShare a Scribd company logo
1
Introduction to ProgrammingIntroduction to Programming
with Pythonwith Python
Porimol Chandro
CSE 32D
World University of Bangladesh
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
Overview
● Background
● Syntax
● Data Types
● Operators
● Control Flow
● Functions
● OOP
● Modules/Packages
● Applications of Python
● Learning Resources
Background
What is Python?
What is Python?
● Interpreted
● High Level Programming Language
● Multi-purpose
● Object Oriented
● Dynamic Typed
● Focus on Readability and Productivity
Features
● Easy to Learn
● Easy to Read
● Cross Platform
● Everything is an Object
● Interactive Shell
● A Broad Standard Library
Who Uses Python?
● Google
● Facebook
● Microsoft
● NASA
● PBS
● ...the list goes on...
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
Any Question?
Syntax
Hello World
C Code:
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}
C++ Code:
#include <iostream.h>
main()
{
cout << "Hello World!";
return 0;
}
Python Code:
print(“Hello World!”)
Java Code:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Indentation
● Most programming language don't care about indentation
● Most humans do
Indentation
C Program:
#include <stdio.h>
int main()
{
if(foo){
print(“Foo Bar”);
} else{
print(“Eita kichu hoilo?”);
}
return 0;
}
Python Program:
if(foo):
print(“Foo Bar”)
else:
print(“Eita kichu hoilo?”)
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
”””
Any Question?
Data Types
Data Types
Python has five standard data types:-
● Numbers
● Strings
● List
● Tuple
● Dictionary
Numbers
● Integer Numbers
var1 = 2017
var2 = int(“2017”)
● Floating Point Numbers
var3 = 3.14159265
var4 = float(“3.14159265”)
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.’’’
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.
List
Blank List
var_list = []
var_list = list()
Numbers
roles = [1, 4, 9, 16, 25]
Float
cgpa = [3.85, 3.94, 3.50, 3.60]
Strings
departments = [“CSE”, “CE”, “EEE”, “BBA”, “ME”]
Combined
combined = [1, “CSE”, “CE”, 2.25, “EEE”, “BBA”, “ME”]
Tuple
Tuple is another data type in python as like List
but the main difference between list and tuple is
that list mutable but tuple immutable.
Tuple
Blank Tuple
roles = ()
roles = tuple()
Numbers
roles = (1, 4, 9, 16, 25)
Float
cgpa = (3.85, 3.94, 3.50, 3.60)
Strings
departments = (“CSE”, “CE”, “EEE”, “BBA”, “ME”)
Combined
combined = (1, “CSE”, “CE”, 2.25, “EEE”, “BBA”, “ME”)
Tuple Unpacking
roles = (1, 4, 9,)
a,b,c = roles
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.
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}
Any Question?
Operators
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
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
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
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)
Any Question?
Control Flow
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?”)
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
Any Question?
Functions
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”)
Any Question?
OOP
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
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.
Objects
Object is simply a collection of data (variables) and methods (functions) that
act on those data.
Example of an Object:
obj = Vehicle()
Any Question?
Modules/Packages
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.
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.
Any Question?
Applications of Python
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...
Any Question?
Learning Resources
● https://docs.python.org/3/tutorial/
● http://python.howtocode.com.bd/
● https://www.programiz.com/python-programming
● https://www.codecademy.com/learn/python
● https://www.tutorialspoint.com/python
● https://www.edx.org/course/subject/computer-science/python
Happy Ending!
Ad

More Related Content

What's hot (20)

Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundation
Kevlin Henney
 
Introduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita GanesanIntroduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita Ganesan
Kavita Ganesan
 
Introduction to IPython & Jupyter Notebooks
Introduction to IPython & Jupyter NotebooksIntroduction to IPython & Jupyter Notebooks
Introduction to IPython & Jupyter Notebooks
Eueung Mulyana
 
constructors in java ppt
constructors in java pptconstructors in java ppt
constructors in java ppt
kunal kishore
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Edureka!
 
Python pandas Library
Python pandas LibraryPython pandas Library
Python pandas Library
Md. Sohag Miah
 
Python Programming Essentials - M9 - String Formatting
Python Programming Essentials - M9 - String FormattingPython Programming Essentials - M9 - String Formatting
Python Programming Essentials - M9 - String Formatting
P3 InfoTech Solutions Pvt. Ltd.
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
Spotle.ai
 
Java String
Java String Java String
Java String
SATYAM SHRIVASTAV
 
Python Basics
Python BasicsPython Basics
Python Basics
tusharpanda88
 
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime modulePython Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime module
P3 InfoTech Solutions Pvt. Ltd.
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
Kamal Acharya
 
Dependency injection
Dependency injectionDependency injection
Dependency injection
Mindfire Solutions
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
Benj Del Mundo
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
7.data types in c#
7.data types in c#7.data types in c#
7.data types in c#
Zeeshan Ahmad
 
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | EdurekaWhat is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
Edureka!
 
Synchronization.37
Synchronization.37Synchronization.37
Synchronization.37
myrajendra
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and Modules
RaginiJain21
 
JavaScript Data Types
JavaScript Data TypesJavaScript Data Types
JavaScript Data Types
Charles Russell
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundation
Kevlin Henney
 
Introduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita GanesanIntroduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita Ganesan
Kavita Ganesan
 
Introduction to IPython & Jupyter Notebooks
Introduction to IPython & Jupyter NotebooksIntroduction to IPython & Jupyter Notebooks
Introduction to IPython & Jupyter Notebooks
Eueung Mulyana
 
constructors in java ppt
constructors in java pptconstructors in java ppt
constructors in java ppt
kunal kishore
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Edureka!
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
Spotle.ai
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
Benj Del Mundo
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | EdurekaWhat is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
Edureka!
 
Synchronization.37
Synchronization.37Synchronization.37
Synchronization.37
myrajendra
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and Modules
RaginiJain21
 

Similar to Introduction to programming with python (20)

Python for dummies
Python for dummiesPython for dummies
Python for dummies
Roberto Stefanetti
 
1P13 Python Review Session Covering various Topics
1P13 Python Review Session Covering various Topics1P13 Python Review Session Covering various Topics
1P13 Python Review Session Covering various Topics
hussainmuhd1119
 
Python Viva Interview Questions PDF By ScholarHat
Python Viva Interview Questions PDF By ScholarHatPython Viva Interview Questions PDF By ScholarHat
Python Viva Interview Questions PDF By ScholarHat
Scholarhat
 
Python
PythonPython
Python
Suman Chandra
 
Python Interview Questions PDF By ScholarHat.pdf
Python Interview Questions PDF By ScholarHat.pdfPython Interview Questions PDF By ScholarHat.pdf
Python Interview Questions PDF By ScholarHat.pdf
Scholarhat
 
PYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day lifePYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
Python Revision Tour.pptx class 12 python notes
Python Revision Tour.pptx class 12 python notesPython Revision Tour.pptx class 12 python notes
Python Revision Tour.pptx class 12 python notes
student164700
 
Python basics
Python basicsPython basics
Python basics
Manisha Gholve
 
The Ring programming language version 1.5.3 book - Part 6 of 184
The Ring programming language version 1.5.3 book - Part 6 of 184The Ring programming language version 1.5.3 book - Part 6 of 184
The Ring programming language version 1.5.3 book - Part 6 of 184
Mahmoud Samir Fayed
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
kavinilavuG
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha Bali
Akanksha Bali
 
The Ring programming language version 1.5.4 book - Part 6 of 185
The Ring programming language version 1.5.4 book - Part 6 of 185The Ring programming language version 1.5.4 book - Part 6 of 185
The Ring programming language version 1.5.4 book - Part 6 of 185
Mahmoud Samir Fayed
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
RojaPriya
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
Mukul Kirti Verma
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptx
Yusuf Ayuba
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
GauravPandey43518
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
Abhishek Tirkey
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
Saraswathi Murugan
 
Pythonppt28 11-18
Pythonppt28 11-18Pythonppt28 11-18
Pythonppt28 11-18
Saraswathi Murugan
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
srinivasanr281952
 
1P13 Python Review Session Covering various Topics
1P13 Python Review Session Covering various Topics1P13 Python Review Session Covering various Topics
1P13 Python Review Session Covering various Topics
hussainmuhd1119
 
Python Viva Interview Questions PDF By ScholarHat
Python Viva Interview Questions PDF By ScholarHatPython Viva Interview Questions PDF By ScholarHat
Python Viva Interview Questions PDF By ScholarHat
Scholarhat
 
Python Interview Questions PDF By ScholarHat.pdf
Python Interview Questions PDF By ScholarHat.pdfPython Interview Questions PDF By ScholarHat.pdf
Python Interview Questions PDF By ScholarHat.pdf
Scholarhat
 
PYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day lifePYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
Python Revision Tour.pptx class 12 python notes
Python Revision Tour.pptx class 12 python notesPython Revision Tour.pptx class 12 python notes
Python Revision Tour.pptx class 12 python notes
student164700
 
The Ring programming language version 1.5.3 book - Part 6 of 184
The Ring programming language version 1.5.3 book - Part 6 of 184The Ring programming language version 1.5.3 book - Part 6 of 184
The Ring programming language version 1.5.3 book - Part 6 of 184
Mahmoud Samir Fayed
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
kavinilavuG
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha Bali
Akanksha Bali
 
The Ring programming language version 1.5.4 book - Part 6 of 185
The Ring programming language version 1.5.4 book - Part 6 of 185The Ring programming language version 1.5.4 book - Part 6 of 185
The Ring programming language version 1.5.4 book - Part 6 of 185
Mahmoud Samir Fayed
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
RojaPriya
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptx
Yusuf Ayuba
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
GauravPandey43518
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
Abhishek Tirkey
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
Saraswathi Murugan
 
Ad

Recently uploaded (20)

Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Ad

Introduction to programming with python

  • 1. 1 Introduction to ProgrammingIntroduction to Programming with Pythonwith Python Porimol Chandro CSE 32D World University of Bangladesh
  • 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 : [email protected]
  • 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
  • 12. Hello World C Code: #include <stdio.h> int main() { printf("Hello World!"); return 0; } C++ Code: #include <iostream.h> main() { cout << "Hello World!"; return 0; } Python Code: print(“Hello World!”) Java Code: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } }
  • 13. Indentation ● Most programming language don't care about indentation ● Most humans do
  • 14. Indentation C Program: #include <stdio.h> int main() { if(foo){ print(“Foo Bar”); } else{ print(“Eita kichu hoilo?”); } return 0; } Python Program: if(foo): print(“Foo Bar”) else: print(“Eita kichu hoilo?”)
  • 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 ”””
  • 18. Data Types Python has five standard data types:- ● Numbers ● Strings ● List ● Tuple ● Dictionary
  • 19. Numbers ● Integer Numbers var1 = 2017 var2 = int(“2017”) ● Floating Point Numbers var3 = 3.14159265 var4 = float(“3.14159265”)
  • 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.
  • 22. List Blank List var_list = [] var_list = list() Numbers roles = [1, 4, 9, 16, 25] Float cgpa = [3.85, 3.94, 3.50, 3.60] Strings departments = [“CSE”, “CE”, “EEE”, “BBA”, “ME”] Combined combined = [1, “CSE”, “CE”, 2.25, “EEE”, “BBA”, “ME”]
  • 23. Tuple Tuple is another data type in python as like List but the main difference between list and tuple is that list mutable but tuple immutable.
  • 24. Tuple Blank Tuple roles = () roles = tuple() Numbers roles = (1, 4, 9, 16, 25) Float cgpa = (3.85, 3.94, 3.50, 3.60) Strings departments = (“CSE”, “CE”, “EEE”, “BBA”, “ME”) Combined combined = (1, “CSE”, “CE”, 2.25, “EEE”, “BBA”, “ME”) Tuple Unpacking roles = (1, 4, 9,) a,b,c = roles
  • 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”)
  • 41. OOP
  • 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...
  • 53. Learning Resources ● https://docs.python.org/3/tutorial/ ● http://python.howtocode.com.bd/ ● https://www.programiz.com/python-programming ● https://www.codecademy.com/learn/python ● https://www.tutorialspoint.com/python ● https://www.edx.org/course/subject/computer-science/python