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

What is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | EdurekaWhat is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | EdurekaEdureka!
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptxAkshayAggarwal79
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data typesMohd Sajjad
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionarySoba Arjun
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in pythonJothi Thilaga P
 
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Edureka!
 
Python tuples and Dictionary
Python   tuples and DictionaryPython   tuples and Dictionary
Python tuples and DictionaryAswini Dharmaraj
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019Samir Mohanty
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| FundamentalsMohd Sajjad
 
Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Edureka!
 
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 | EdurekaEdureka!
 
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 Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming LanguageMansiSuthar3
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python amiable_indian
 
Variables in python
Variables in pythonVariables in python
Variables in pythonJaya Kumari
 

What's hot (20)

What is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | EdurekaWhat is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | Edureka
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data types
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
 
Python tuples and Dictionary
Python   tuples and DictionaryPython   tuples and Dictionary
Python tuples and Dictionary
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...
 
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
 
Python ppt
Python pptPython ppt
Python ppt
 
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 Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Python basic
Python basicPython basic
Python basic
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
Variables in python
Variables in pythonVariables in python
Variables in python
 

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
 
Analysis Mechanical system using Artificial intelligence
Analysis Mechanical system using Artificial intelligenceAnalysis Mechanical system using Artificial intelligence
Analysis Mechanical system using Artificial intelligenceanishahmadgrd222
 
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
 
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
 
Analysis Mechanical system using Artificial intelligence
Analysis Mechanical system using Artificial intelligenceAnalysis Mechanical system using Artificial intelligence
Analysis Mechanical system using Artificial intelligence
 
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

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Recently uploaded (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

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