SlideShare a Scribd company logo
Introduction to Python

a readable, dynamic, pleasant, 

flexible, fast and powerful language.
Murtadha Bazli Tukimat

Developer/Founder at Wekanta

bazli@wekanta.com
Wekanta
Overview
๏ Background
๏ Syntax
๏ Variables
๏ Data Structure
๏ Comparison
๏ Control Flow
๏ Function
Wekanta
What is Python?
• Python is a dynamic, interpreted (bytecode-compiled) and
multi-platform language

• No type declarations of variables, parameters, functions,
or methods in source code

• Code become short and fast to compile
Wekanta
Why Python?
• Machine learning, NLP and data scientific tools packages

• From embedded system to the web applications

(Web, GUI, Scripting, etc.)

• A general purpose language



Read it more → https://goo.gl/ZwtjJV
Wekanta
Syntax
๏ Hello World!
๏ Indentation
๏ Naming Convention
๏ Comment
Wekanta
#!/usr/local/bin/python3

print(“hello world!”)
Hello World!
Wekanta
• Indentation affects code's meaning

• End of the line means end of the statement

• Inconsistent indentation == Syntax Error

• Tabs vs Spaces?

Spaces are the preferred indentation method.
Indentation
Wekanta
Indentation Cont'd
If foo:

If bar:

print('Hello World')
else:

print('Welcome to Python')
Wekanta
• b (single lowercase)
• B (single uppercase)

• lowercase
• lower_case_underscore
• UPPERCASE

• UPPER_CASE_UNDERSCORE

• CamelCase
• mixedCase

• Camel_Case_Underscore (ugly)
Naming Convention
Wekanta
# This is single line comment

' This is also single line comment '

' This is a single line comment too '

'''

This is example of

multi-line comment.

'''
Comment
Wekanta
Variables
๏ String
๏ Number
๏ Boolean
๏ Null
Wekanta
String
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# declaration

s = 'hello python'



# methods

s.lower() # return string lowercase version

s.upper() # return string uppercase version

s.strip() # remove trailing & leading whitespaces

s.isalpha() # alphanumeric test

s.isdigit() # digit/number test

s.isspace() # spaces test

s.startswith('hello') # check if string start with 'foo'

s.endswith('python') # check if string ending with 'bar'

s.find('hello') # return 'foo' index

s.replace('hello', 'hi') # replace 'foo' with 'bar' string

s.split('hello') # return list of substrings

s.join(list) # opposite of split
Wekanta
String Cont'd
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

s = 'Hello, this is Python '



s.lower() # 'hello, this is python '

s.upper() # 'HELLO, THIS IS PYTHON '

s.strip() # 'Hello, this is Python'

s.lower().find('hello') # 0

s.replace('this', 'that') # 'Hello, that is Python '

s = s.split(',') # ['Hello', ' this is Python ']

','.join(s) # 'Hello, this is Python '
Wekanta
Number
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# integer number

year = 2010

year = int('2010')

# floating point number

temperature = 27.6

temperature = float('27.6')

# fixed point number

price = Decimal('12.50')
Wekanta
Boolean
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

is_python = True

# cast to any variables

is_python = bool(0)

is_python = bool('check')
Wekanta
Null
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
optional_data = None
Wekanta
Data Structure
๏ List
๏ Dictionary
Wekanta
List
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# declaration

list = []

list = list()

# methods

list.append(element)

list.extend(list2)

list.insert(index, element)

list.remove(element)

list.pop(index)

list.clear()

list.index(element)

list.count(element)

list.sort()

list.reverse()

list.copy()
Wekanta
List Cont'd
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

list = ['bazli', 'hidayah', 'nabila']



list.append('others')         # append 'others' at end

list.extend(['yyy', 'zzz'])   # add list of element at end

list.insert(0, 'xxx')         # insert 'xxx' at index 0
print(list)

# ['xxx', 'bazli', 'hidayah', 'nabila', 'others', 'yyy', 'zzz']



print(list.index('bazli'))    # 1

list.remove('bazli')         # search and remove that element

list.pop(1)                   # removes and returns 'larry'
print(list.count('xxx')) # 1

print(list)

# ['xxx', 'nabila', 'others', 'yyy', 'zzz']

Wekanta
List Slices
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

list = ['a', 'b', 'c', 'd']



print(list[1:-1])  # ['b', 'c']

print(list[:-1])   # ['a', 'b', 'c']



list[0:2] = 'z'    # replace ['a', 'b'] with 'z'



print(list)        # ['z', 'c', 'd']
Wekanta
Dictionary
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# declaration

dict = {}

dict = dict()



# methods

dict.clear()

dict.copy()

dict.get()

dict.items()

dict.keys()

dict.pop()

dict.update()

dict.values()
Wekanta
Dictionary Cont'd
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

product = {'name': 'sensor', 'price': 25.0}



product['name'] = 'device' # set 'name' to 'device'

print(product['name']) # temperature sensor

product.get('name') # sensor

product.keys() # ['name', 'price']

product.pop('name') # remove key 'name'

product.values() # ['sensor', 25.0]



product.update({'price': 20.0}) # update price value

product.items() # [ ['name', 'sensor'], ['price', 25.0] ]
Wekanta
Dictionary Hash Table
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

dict = {}

dict['a'] = 'alpha'

dict['o'] = 'omega'

dict['g'] = 'gamma'



print(dict[‘a']) # 'alpha'

print(dict)

# {'a': 'alpha', 'o': 'omega', 'g': 'gamma'}
Wekanta
Comparison
๏ Operator
๏ Logical
๏ Identity
Wekanta
Operator
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
== # Equal



!= # Not equal



<> # Not equal



>= # More than or equal



<= # Less than or equal



> # More than



< # Less than
Wekanta
Logical Comparison
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# Logical AND

a and b



# Logical OR

a or b



# Logical Negation

not a



# Compound

(a and not (a or b)
Wekanta
Identity Comparison
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# identity

1 is 1 == True



# non identity

1 is not '1' == True
Wekanta
Control Flow
๏ Conditional
๏ For Loop
๏ While Loop
๏ List Comprehension
Wekanta
Conditional
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

price = 25.0



if price >= 20:

print('Expensive')

elif 20 > price >= 10:

print('Cheap')

else:

print('Super Cheap')
Wekanta
For Loop
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

docs = { 'name': 'sensor', 'price': 25.0 }



# iterate by range

for x in range(10):

print(x)

# 0, 1, 2 ….



# iterate by element / dictionary keys

for doc in docs:

print(doc)

# name, price



# expanded for-loop

for k, v in docs:

print(k, v)
Wekanta
While Loop
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# infinite

while True:

print(‘running…’)



# conditional

while x < 10:

print(‘running…’)

x += 1
Wekanta
List Comprehension
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

docs = [{'name': 'Arduino', 'price': 180.0},

{'name': 'Raspberry Pi', 'price': 200.0}]



# common method

new_list = []

for d in docs:

if d['price'] < 200:

new_list.append(d['name'])



# list comprehension method

new_list = [d['name'] for d in docs if d[‘price'] < 200]

# ['Arduino']
Wekanta
Function
๏ Function Argument
๏ Arbitrary Argument
Wekanta
Function Argument
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# basic function

def my_function():

''' Function Documentation '''

pass



# keyword argument

def price_check(price, currency='MYR'):

''' Check Price '''

pass
Wekanta
Arbitrary Argument
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
*args is non-keyworded arguments

# my_function(1, 2, 3)



**kwargs is keyworded arguments

# my_function(price=42)

Wekanta
Arbitrary Argument Cont’d
# This is single line comment

'This is also single line comment'

'''

This is example of

multi-line comment.

'''
# example

def my_function(*args, **kwargs):

''' Function Documentation '''

for arg in args:

print(arg)



for key, value in kwargs.items():

print(key, value)



# usage

my_function(1, 2, currency='MYR')



# results

1

2

currency MYR
Wekanta
Q&A
Wekanta
Ad

More Related Content

What's hot (14)

Os Borger
Os BorgerOs Borger
Os Borger
oscon2007
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentation
Manav Prasad
 
P H P Part I, By Kian
P H P  Part  I,  By  KianP H P  Part  I,  By  Kian
P H P Part I, By Kian
phelios
 
Designing Ruby APIs
Designing Ruby APIsDesigning Ruby APIs
Designing Ruby APIs
Wen-Tien Chang
 
Subroutines
SubroutinesSubroutines
Subroutines
primeteacher32
 
Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to hero
Diego Lemos
 
In-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTMLIn-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTML
eSparkBiz
 
Lecture 2 php basics (1)
Lecture 2  php basics (1)Lecture 2  php basics (1)
Lecture 2 php basics (1)
Core Lee
 
Ruby_Basic
Ruby_BasicRuby_Basic
Ruby_Basic
Kushal Jangid
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
Ahmed Swilam
 
ppt18
ppt18ppt18
ppt18
callroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
callroom
 
ppt9
ppt9ppt9
ppt9
callroom
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
callroom
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentation
Manav Prasad
 
P H P Part I, By Kian
P H P  Part  I,  By  KianP H P  Part  I,  By  Kian
P H P Part I, By Kian
phelios
 
Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to hero
Diego Lemos
 
In-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTMLIn-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTML
eSparkBiz
 
Lecture 2 php basics (1)
Lecture 2  php basics (1)Lecture 2  php basics (1)
Lecture 2 php basics (1)
Core Lee
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
Ahmed Swilam
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
callroom
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
callroom
 

Similar to Introduction to Python by Wekanta (20)

String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeString handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
UNIT II (7).pptx
UNIT II (7).pptxUNIT II (7).pptx
UNIT II (7).pptx
DrDhivyaaCRAssistant
 
UNIT II (7).pptx
UNIT II (7).pptxUNIT II (7).pptx
UNIT II (7).pptx
DrDhivyaaCRAssistant
 
JNTUK r20 AIML SOC NLP-LAB-MANUAL-R20.docx
JNTUK r20 AIML SOC NLP-LAB-MANUAL-R20.docxJNTUK r20 AIML SOC NLP-LAB-MANUAL-R20.docx
JNTUK r20 AIML SOC NLP-LAB-MANUAL-R20.docx
bslsdevi
 
Improve Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptxImprove Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptx
CatherineVania1
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
baabtra.com - No. 1 supplier of quality freshers
 
Python basic
Python basicPython basic
Python basic
Saifuddin Kaijar
 
Python- Basic. pptx with lists, tuples dictionaries and data types
Python- Basic. pptx with lists, tuples dictionaries and data typesPython- Basic. pptx with lists, tuples dictionaries and data types
Python- Basic. pptx with lists, tuples dictionaries and data types
harinithiyagarajan4
 
Python- Basic.pptx with data types, lists, and tuples with dictionary
Python- Basic.pptx with data types, lists, and tuples with dictionaryPython- Basic.pptx with data types, lists, and tuples with dictionary
Python- Basic.pptx with data types, lists, and tuples with dictionary
harinithiyagarajan4
 
php_string.pdf
php_string.pdfphp_string.pdf
php_string.pdf
Sharon Manmothe
 
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
manikbuma
 
industry coding practice unit-2 ppt.pptx
industry coding practice unit-2 ppt.pptxindustry coding practice unit-2 ppt.pptx
industry coding practice unit-2 ppt.pptx
LakshmiMarineni
 
AOS_Module_3ssssssssssssssssssssssssssss.pptx
AOS_Module_3ssssssssssssssssssssssssssss.pptxAOS_Module_3ssssssssssssssssssssssssssss.pptx
AOS_Module_3ssssssssssssssssssssssssssss.pptx
rapiwip803
 
introduction to javascript concepts .ppt
introduction to javascript concepts .pptintroduction to javascript concepts .ppt
introduction to javascript concepts .ppt
ansariparveen06
 
Sanjana - Python--(presentation) comp. science .pptx
Sanjana - Python--(presentation) comp. science .pptxSanjana - Python--(presentation) comp. science .pptx
Sanjana - Python--(presentation) comp. science .pptx
SanjanaSharma582210
 
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
rani marri
 
Lecture06
Lecture06Lecture06
Lecture06
elearning_portal
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
Sumit Raj
 
Case, Loop & Command line args un Unix
Case, Loop & Command line args un UnixCase, Loop & Command line args un Unix
Case, Loop & Command line args un Unix
Vpmv
 
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeString handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
JNTUK r20 AIML SOC NLP-LAB-MANUAL-R20.docx
JNTUK r20 AIML SOC NLP-LAB-MANUAL-R20.docxJNTUK r20 AIML SOC NLP-LAB-MANUAL-R20.docx
JNTUK r20 AIML SOC NLP-LAB-MANUAL-R20.docx
bslsdevi
 
Improve Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptxImprove Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptx
CatherineVania1
 
Python- Basic. pptx with lists, tuples dictionaries and data types
Python- Basic. pptx with lists, tuples dictionaries and data typesPython- Basic. pptx with lists, tuples dictionaries and data types
Python- Basic. pptx with lists, tuples dictionaries and data types
harinithiyagarajan4
 
Python- Basic.pptx with data types, lists, and tuples with dictionary
Python- Basic.pptx with data types, lists, and tuples with dictionaryPython- Basic.pptx with data types, lists, and tuples with dictionary
Python- Basic.pptx with data types, lists, and tuples with dictionary
harinithiyagarajan4
 
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
manikbuma
 
industry coding practice unit-2 ppt.pptx
industry coding practice unit-2 ppt.pptxindustry coding practice unit-2 ppt.pptx
industry coding practice unit-2 ppt.pptx
LakshmiMarineni
 
AOS_Module_3ssssssssssssssssssssssssssss.pptx
AOS_Module_3ssssssssssssssssssssssssssss.pptxAOS_Module_3ssssssssssssssssssssssssssss.pptx
AOS_Module_3ssssssssssssssssssssssssssss.pptx
rapiwip803
 
introduction to javascript concepts .ppt
introduction to javascript concepts .pptintroduction to javascript concepts .ppt
introduction to javascript concepts .ppt
ansariparveen06
 
Sanjana - Python--(presentation) comp. science .pptx
Sanjana - Python--(presentation) comp. science .pptxSanjana - Python--(presentation) comp. science .pptx
Sanjana - Python--(presentation) comp. science .pptx
SanjanaSharma582210
 
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
rani marri
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
Sumit Raj
 
Case, Loop & Command line args un Unix
Case, Loop & Command line args un UnixCase, Loop & Command line args un Unix
Case, Loop & Command line args un Unix
Vpmv
 
Ad

Recently uploaded (20)

Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
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
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
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
 
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
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
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
 
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
 
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
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
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
 
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
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
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
 
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
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
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
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
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
 
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
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
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
 
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
 
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
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
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
 
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
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
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
 
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
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Ad

Introduction to Python by Wekanta

  • 1. Introduction to Python
 a readable, dynamic, pleasant, flexible, fast and powerful language. Murtadha Bazli Tukimat
 Developer/Founder at Wekanta
 [email protected] Wekanta
  • 2. Overview ๏ Background ๏ Syntax ๏ Variables ๏ Data Structure ๏ Comparison ๏ Control Flow ๏ Function Wekanta
  • 3. What is Python? • Python is a dynamic, interpreted (bytecode-compiled) and multi-platform language • No type declarations of variables, parameters, functions, or methods in source code • Code become short and fast to compile Wekanta
  • 4. Why Python? • Machine learning, NLP and data scientific tools packages • From embedded system to the web applications
 (Web, GUI, Scripting, etc.) • A general purpose language 
 Read it more → https://goo.gl/ZwtjJV Wekanta
  • 5. Syntax ๏ Hello World! ๏ Indentation ๏ Naming Convention ๏ Comment Wekanta
  • 7. • Indentation affects code's meaning • End of the line means end of the statement • Inconsistent indentation == Syntax Error • Tabs vs Spaces?
 Spaces are the preferred indentation method. Indentation Wekanta
  • 8. Indentation Cont'd If foo:
 If bar:
 print('Hello World') else:
 print('Welcome to Python') Wekanta
  • 9. • b (single lowercase) • B (single uppercase) • lowercase • lower_case_underscore • UPPERCASE • UPPER_CASE_UNDERSCORE • CamelCase • mixedCase • Camel_Case_Underscore (ugly) Naming Convention Wekanta
  • 10. # This is single line comment ' This is also single line comment ' ' This is a single line comment too ' '''
 This is example of
 multi-line comment.
 ''' Comment Wekanta
  • 11. Variables ๏ String ๏ Number ๏ Boolean ๏ Null Wekanta
  • 12. String # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # declaration
 s = 'hello python'
 
 # methods
 s.lower() # return string lowercase version
 s.upper() # return string uppercase version
 s.strip() # remove trailing & leading whitespaces
 s.isalpha() # alphanumeric test
 s.isdigit() # digit/number test
 s.isspace() # spaces test
 s.startswith('hello') # check if string start with 'foo'
 s.endswith('python') # check if string ending with 'bar'
 s.find('hello') # return 'foo' index
 s.replace('hello', 'hi') # replace 'foo' with 'bar' string
 s.split('hello') # return list of substrings
 s.join(list) # opposite of split Wekanta
  • 13. String Cont'd # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 s = 'Hello, this is Python '
 
 s.lower() # 'hello, this is python '
 s.upper() # 'HELLO, THIS IS PYTHON '
 s.strip() # 'Hello, this is Python'
 s.lower().find('hello') # 0
 s.replace('this', 'that') # 'Hello, that is Python '
 s = s.split(',') # ['Hello', ' this is Python ']
 ','.join(s) # 'Hello, this is Python ' Wekanta
  • 14. Number # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # integer number
 year = 2010
 year = int('2010') # floating point number
 temperature = 27.6
 temperature = float('27.6') # fixed point number
 price = Decimal('12.50') Wekanta
  • 15. Boolean # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 is_python = True # cast to any variables
 is_python = bool(0)
 is_python = bool('check') Wekanta
  • 16. Null # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' optional_data = None Wekanta
  • 17. Data Structure ๏ List ๏ Dictionary Wekanta
  • 18. List # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # declaration
 list = []
 list = list() # methods
 list.append(element)
 list.extend(list2)
 list.insert(index, element)
 list.remove(element)
 list.pop(index)
 list.clear()
 list.index(element)
 list.count(element)
 list.sort()
 list.reverse()
 list.copy() Wekanta
  • 19. List Cont'd # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 list = ['bazli', 'hidayah', 'nabila']
 
 list.append('others')         # append 'others' at end
 list.extend(['yyy', 'zzz'])   # add list of element at end
 list.insert(0, 'xxx')         # insert 'xxx' at index 0 print(list)
 # ['xxx', 'bazli', 'hidayah', 'nabila', 'others', 'yyy', 'zzz']
 
 print(list.index('bazli'))    # 1
 list.remove('bazli')         # search and remove that element
 list.pop(1)                   # removes and returns 'larry' print(list.count('xxx')) # 1
 print(list)
 # ['xxx', 'nabila', 'others', 'yyy', 'zzz']
 Wekanta
  • 20. List Slices # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 list = ['a', 'b', 'c', 'd']
 
 print(list[1:-1])  # ['b', 'c']
 print(list[:-1])   # ['a', 'b', 'c']
 
 list[0:2] = 'z'    # replace ['a', 'b'] with 'z'
 
 print(list)        # ['z', 'c', 'd'] Wekanta
  • 21. Dictionary # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # declaration
 dict = {}
 dict = dict()
 
 # methods
 dict.clear()
 dict.copy()
 dict.get()
 dict.items()
 dict.keys()
 dict.pop()
 dict.update()
 dict.values() Wekanta
  • 22. Dictionary Cont'd # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 product = {'name': 'sensor', 'price': 25.0}
 
 product['name'] = 'device' # set 'name' to 'device'
 print(product['name']) # temperature sensor
 product.get('name') # sensor
 product.keys() # ['name', 'price']
 product.pop('name') # remove key 'name'
 product.values() # ['sensor', 25.0]
 
 product.update({'price': 20.0}) # update price value
 product.items() # [ ['name', 'sensor'], ['price', 25.0] ] Wekanta
  • 23. Dictionary Hash Table # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 dict = {}
 dict['a'] = 'alpha'
 dict['o'] = 'omega'
 dict['g'] = 'gamma'
 
 print(dict[‘a']) # 'alpha'
 print(dict)
 # {'a': 'alpha', 'o': 'omega', 'g': 'gamma'} Wekanta
  • 25. Operator # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' == # Equal
 
 != # Not equal
 
 <> # Not equal
 
 >= # More than or equal
 
 <= # Less than or equal
 
 > # More than
 
 < # Less than Wekanta
  • 26. Logical Comparison # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # Logical AND
 a and b
 
 # Logical OR
 a or b
 
 # Logical Negation
 not a
 
 # Compound
 (a and not (a or b) Wekanta
  • 27. Identity Comparison # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # identity
 1 is 1 == True
 
 # non identity
 1 is not '1' == True Wekanta
  • 28. Control Flow ๏ Conditional ๏ For Loop ๏ While Loop ๏ List Comprehension Wekanta
  • 29. Conditional # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 price = 25.0
 
 if price >= 20:
 print('Expensive')
 elif 20 > price >= 10:
 print('Cheap')
 else:
 print('Super Cheap') Wekanta
  • 30. For Loop # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 docs = { 'name': 'sensor', 'price': 25.0 }
 
 # iterate by range
 for x in range(10):
 print(x)
 # 0, 1, 2 ….
 
 # iterate by element / dictionary keys
 for doc in docs:
 print(doc)
 # name, price
 
 # expanded for-loop
 for k, v in docs:
 print(k, v) Wekanta
  • 31. While Loop # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # infinite
 while True:
 print(‘running…’)
 
 # conditional
 while x < 10:
 print(‘running…’)
 x += 1 Wekanta
  • 32. List Comprehension # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 docs = [{'name': 'Arduino', 'price': 180.0},
 {'name': 'Raspberry Pi', 'price': 200.0}]
 
 # common method
 new_list = []
 for d in docs:
 if d['price'] < 200:
 new_list.append(d['name'])
 
 # list comprehension method
 new_list = [d['name'] for d in docs if d[‘price'] < 200]
 # ['Arduino'] Wekanta
  • 33. Function ๏ Function Argument ๏ Arbitrary Argument Wekanta
  • 34. Function Argument # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # basic function
 def my_function():
 ''' Function Documentation '''
 pass
 
 # keyword argument
 def price_check(price, currency='MYR'):
 ''' Check Price '''
 pass Wekanta
  • 35. Arbitrary Argument # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' *args is non-keyworded arguments
 # my_function(1, 2, 3)
 
 **kwargs is keyworded arguments
 # my_function(price=42) Wekanta
  • 36. Arbitrary Argument Cont’d # This is single line comment 'This is also single line comment' '''
 This is example of
 multi-line comment.
 ''' # example
 def my_function(*args, **kwargs):
 ''' Function Documentation '''
 for arg in args:
 print(arg)
 
 for key, value in kwargs.items():
 print(key, value)
 
 # usage
 my_function(1, 2, currency='MYR')
 
 # results
 1
 2
 currency MYR Wekanta