SlideShare a Scribd company logo
1 of 54
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!

More Related Content

What's hot

Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019Samir Mohanty
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAgung Wahyudi
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonMohammed Rafi
 
Phython Programming Language
Phython Programming LanguagePhython Programming Language
Phython Programming LanguageR.h. Himel
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Pedro Rodrigues
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programmingSrinivas Narasegouda
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python pptPriyanka Pradhan
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in pythonKarin Lagesen
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in PythonSumit Satam
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-pythonAakashdata
 
Python presentation by Monu Sharma
Python presentation by Monu SharmaPython presentation by Monu Sharma
Python presentation by Monu SharmaMayank Sharma
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An IntroductionSwarit Wadhe
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Python Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | EdurekaPython Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | EdurekaEdureka!
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slidesrfojdar
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaEdureka!
 

What's hot (20)

Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Phython Programming Language
Phython Programming LanguagePhython Programming Language
Phython Programming Language
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in python
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
Python presentation by Monu Sharma
Python presentation by Monu SharmaPython presentation by Monu Sharma
Python presentation by Monu Sharma
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | EdurekaPython Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | Edureka
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
Python basics
Python basicsPython basics
Python basics
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | Edureka
 

Similar to Introduction to programming with python

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 184Mahmoud Samir Fayed
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answerskavinilavuG
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha BaliAkanksha 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 185Mahmoud Samir Fayed
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answersRojaPriya
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptxYusuf 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).pptxAbhishek Tirkey
 
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).pptxGauravPandey43518
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE Saraswathi Murugan
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsRuth Marvin
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptxNileshBorkar12
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptxrohithprabhas1
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Jitendra Bafna
 

Similar to Introduction to programming with python (20)

Python for dummies
Python for dummiesPython for dummies
Python for dummies
 
Python
PythonPython
Python
 
Python basics
Python basicsPython basics
Python basics
 
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
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by 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
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptx
 
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
 
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
 
Pythonppt28 11-18
Pythonppt28 11-18Pythonppt28 11-18
Pythonppt28 11-18
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_arguments
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptx
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

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 : 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
  • 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