SlideShare a Scribd company logo
Python in 90 minutes
Bardia Heydari nejad
What is Python?
What normal people think What I think
Why Python?
• It’s multiiiiiiiiiiiiiiii purpose 😃
Web, GUI, Scripting, Data mining, Artificial intelligence ….
• It’s Readable 😊
No goddamn semicolon;
• It’s Productive 😮
10 times faster than C too produce a software
about Python
• interpreted: no more compiling no more binaries
• object-oriented: but you are not forced
• strongly-typed: explicits are better than implicit
• dynamically-typed: simple is better than complex
• cross platform: everywhere that interpreted exists
• indenting is a must: beautiful is better than ugly
• every thing is object
Hello, world!
#include<iostream>
using namespace std;
int main()
{
cout<<“Hello, world!”;
return 0;
}
C++
Hello, world!
public class Program {
public static main(string[] argus){
System.out.println(“Hello, world!”);
}
}
Java
Hello, world!
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo ‘<p>Hello, world!</p>’; ?>
</body>
</html>
PHP
Hello, world!
print “Hello, world!”
Python
Operator
• +
• -
• *
• /
• //
• **
• %
• ==
• !=
• >
• <
• >=
• <=
• +=
• -=
• *=
• /=
• **=
• //=
• &
• |
• ^
• ~
• >>
• <<
• and
• or
• not
• in
• is
Variables
•int i = 1
•float f = 2.1
•bool b = False
•str s = ‘hi’
•list l = [1, 2, “hello again”, 4]
•tuple t = (True, 2.1)
•dict d = {1:”One”, 2:”Two”}
•set s = {“some”, “unique”, “objects”}
Variables - Assignment
>>> dummy_variable = 2
>>> dummy_variable = ‘hi’
>>> a, b = 2, 3
>>> a, b = b, a
int
main()
{
int
a
=
2,
b
=
3
,
k;
k
=
a;
a
=
b;
b
=
a;
return
0;
}
in c++
Variables - Casting
>>> float(1)
1.0
>>> str(1)
‘1’
>>> int(‘1’)
1
>>> list(1)
[1, ]
>>> list(‘hello’)
['h', 'e', 'l', 'l', ‘o']
>>> set([1, 0, 1, 1, 0, 1, 0, 0])
set([1, 0])
String
• concatenate
• slice
• find
• replace
• count
• capitalize
List
• slice
• concatenate
• sort
• append - pop - remove - insert
Condition
• if
• elif
• else
Loop
• while
• for
• else
Function
• Keyword arguments
• Default arguments
• Functions are objects
Question?
Object oriented
• Event classes are object
• Dynamically add attributes
• Static methods and attributes
• Property
Beyond OO
reflection/introspection
• type(obj)
• isinstance(obj, class)
• issubclass(class, class)
• getattr(obj, key) / hastattr(obj, key)
First class functions
• function assignment
• send function as parameter
• callable objects
Strategy pattern


class Player: 

def __init__(self, play_behavior): 

self.play_behavior = play_behavior 



def play(self): 

return self.play_behavior 





def attack(): 

print("I attack”) 



attacker = Player(attack) .
Closure pattern
• function in function
def add(x): 

def add2(y): 

return x + y 

return add2
or with lambda
def add(x): 

return lambda y: x+y
• callable
class Add: 

def __init__(self, x): 

self.x = x 



def __call__(self, y): 

return self.x + y 

Generator pattern
• subroutine vs co-routine


def get_primes(number): 

while True: 

if is_prime(number): 

yield number 

number += 1




def solve_number_10(): 

total = 0 

for next_prime in get_primes(2): 

if next_prime < 2000000: 

total += next_prime 

else: 

break 

print(total)
Decorator pattern
def register_function(f): 

print("%s function is registered" % f.__name__) 

return f 





@register_function 

def do_dummy_stuff(): 

return 1


Decorator pattern
add some tricks
def log(f): 

def logger_function(*args, **kwargs): 

result = f(*args, **kwargs) 

print("Result: %s" % result) 

return result 



return logger_function




@log 

def do_dummy_stuff(): 

return 1
Decorator pattern
add some tricks
def log(level=‘DEBUG'): 

def decorator(f): 

def logger_function(*args, **kwargs): 

result = f(*args, **kwargs) 

print("%s: %s" % (level, result)) 

return result 



return logger_function 



return decorator 





@log(level=‘INFO') 

def do_dummy_stuff(): 

return 1
Complex syntax
One-line if:
print('even' if i % 2 == 0 else 'odd')

One line for:
l = [num ** 2 for num in numbers]

None or … :
value = dummy_function_may_return_none() or 0


Question?

More Related Content

What's hot

Learn python in 20 minutes
Learn python in 20 minutesLearn python in 20 minutes
Learn python in 20 minutes
Sidharth Nadhan
 
Python
PythonPython
Python
대갑 김
 
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
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on Python
Sumit Raj
 
Introduction to the basics of Python programming (part 3)
Introduction to the basics of Python programming (part 3)Introduction to the basics of Python programming (part 3)
Introduction to the basics of Python programming (part 3)
Pedro Rodrigues
 
An introduction to Python for absolute beginners
An introduction to Python for absolute beginnersAn introduction to Python for absolute beginners
An introduction to Python for absolute beginners
Kálmán "KAMI" Szalai
 
Porting to Python 3
Porting to Python 3Porting to Python 3
Porting to Python 3
Lennart Regebro
 
Python: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersPython: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopers
Glenn De Backer
 
python codes
python codespython codes
python codes
tusharpanda88
 
Python language data types
Python language data typesPython language data types
Python language data types
Hoang Nguyen
 
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina ZakharenkoElegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
Nina Zakharenko
 
Python Tutorial
Python TutorialPython Tutorial
Python Tutorial
Eueung Mulyana
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ahmed Salama
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
Marwan Osman
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
Maulik Borsaniya
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!
Paige Bailey
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
Santosh Rajan
 
Programming in Python
Programming in Python Programming in Python
Programming in Python
Tiji Thomas
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
RajKumar Rampelli
 

What's hot (20)

Learn python in 20 minutes
Learn python in 20 minutesLearn python in 20 minutes
Learn python in 20 minutes
 
Python
PythonPython
Python
 
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)
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on Python
 
Introduction to the basics of Python programming (part 3)
Introduction to the basics of Python programming (part 3)Introduction to the basics of Python programming (part 3)
Introduction to the basics of Python programming (part 3)
 
An introduction to Python for absolute beginners
An introduction to Python for absolute beginnersAn introduction to Python for absolute beginners
An introduction to Python for absolute beginners
 
Porting to Python 3
Porting to Python 3Porting to Python 3
Porting to Python 3
 
Python: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersPython: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopers
 
python codes
python codespython codes
python codes
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina ZakharenkoElegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
 
Python Tutorial
Python TutorialPython Tutorial
Python Tutorial
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!
 
python.ppt
python.pptpython.ppt
python.ppt
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
 
Programming in Python
Programming in Python Programming in Python
Programming in Python
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
 

Viewers also liked

تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانیتست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
irpycon
 
Apache spark session
Apache spark sessionApache spark session
Apache spark session
knowbigdata
 
Concurrency and scalability with akka
Concurrency and scalability  with akkaConcurrency and scalability  with akka
Concurrency and scalability with akka
Bardia Heydari
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
Tahani Al-Manie
 
Concurrency in Scala - the Akka way
Concurrency in Scala - the Akka wayConcurrency in Scala - the Akka way
Concurrency in Scala - the Akka wayYardena Meymann
 
A Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonA Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with Python
Tariq Rashid
 

Viewers also liked (6)

تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانیتست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
 
Apache spark session
Apache spark sessionApache spark session
Apache spark session
 
Concurrency and scalability with akka
Concurrency and scalability  with akkaConcurrency and scalability  with akka
Concurrency and scalability with akka
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
Concurrency in Scala - the Akka way
Concurrency in Scala - the Akka wayConcurrency in Scala - the Akka way
Concurrency in Scala - the Akka way
 
A Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonA Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with Python
 

Similar to Python in 90 minutes

Intro to Python
Intro to PythonIntro to Python
Intro to Python
Daniel Greenfeld
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
Angela Byron
 
Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
Kenneth Geisshirt
 
On the Edge Systems Administration with Golang
On the Edge Systems Administration with GolangOn the Edge Systems Administration with Golang
On the Edge Systems Administration with Golang
Chris McEniry
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
Hermes Alves
 
Giving back with GitHub - Putting the Open Source back in iOS
Giving back with GitHub - Putting the Open Source back in iOSGiving back with GitHub - Putting the Open Source back in iOS
Giving back with GitHub - Putting the Open Source back in iOS
Madhava Jay
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
Charles Nutter
 
Intro to kotlin 2018
Intro to kotlin 2018Intro to kotlin 2018
Intro to kotlin 2018
Shady Selim
 
обзор Python
обзор Pythonобзор Python
обзор Python
Yehor Nazarkin
 
Python_Unit_2 OOPS.pptx
Python_Unit_2  OOPS.pptxPython_Unit_2  OOPS.pptx
Python_Unit_2 OOPS.pptx
ChhaviCoachingCenter
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
Mike Dirolf
 
Python Novice to Ninja
Python Novice to NinjaPython Novice to Ninja
Python Novice to Ninja
Al Sayed Gamal
 
Fabric
FabricFabric
FabricJS Lee
 
Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data managementPython and Oracle : allies for best of data management
Python and Oracle : allies for best of data management
Laurent Leturgez
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
Roman Elizarov
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
jehan1987
 
Boost Maintainability
Boost MaintainabilityBoost Maintainability
Boost Maintainability
Mosky Liu
 

Similar to Python in 90 minutes (20)

Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Intro
IntroIntro
Intro
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
 
TDD with phpspec2
TDD with phpspec2TDD with phpspec2
TDD with phpspec2
 
Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
 
On the Edge Systems Administration with Golang
On the Edge Systems Administration with GolangOn the Edge Systems Administration with Golang
On the Edge Systems Administration with Golang
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
 
Giving back with GitHub - Putting the Open Source back in iOS
Giving back with GitHub - Putting the Open Source back in iOSGiving back with GitHub - Putting the Open Source back in iOS
Giving back with GitHub - Putting the Open Source back in iOS
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
Intro to kotlin 2018
Intro to kotlin 2018Intro to kotlin 2018
Intro to kotlin 2018
 
обзор Python
обзор Pythonобзор Python
обзор Python
 
Python_Unit_2 OOPS.pptx
Python_Unit_2  OOPS.pptxPython_Unit_2  OOPS.pptx
Python_Unit_2 OOPS.pptx
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
Python Novice to Ninja
Python Novice to NinjaPython Novice to Ninja
Python Novice to Ninja
 
Fabric
FabricFabric
Fabric
 
Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data managementPython and Oracle : allies for best of data management
Python and Oracle : allies for best of data management
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
 
Boost Maintainability
Boost MaintainabilityBoost Maintainability
Boost Maintainability
 

Recently uploaded

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 

Recently uploaded (20)

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 

Python in 90 minutes

  • 1. Python in 90 minutes Bardia Heydari nejad
  • 2. What is Python? What normal people think What I think
  • 3. Why Python? • It’s multiiiiiiiiiiiiiiii purpose 😃 Web, GUI, Scripting, Data mining, Artificial intelligence …. • It’s Readable 😊 No goddamn semicolon; • It’s Productive 😮 10 times faster than C too produce a software
  • 4. about Python • interpreted: no more compiling no more binaries • object-oriented: but you are not forced • strongly-typed: explicits are better than implicit • dynamically-typed: simple is better than complex • cross platform: everywhere that interpreted exists • indenting is a must: beautiful is better than ugly • every thing is object
  • 5. Hello, world! #include<iostream> using namespace std; int main() { cout<<“Hello, world!”; return 0; } C++
  • 6. Hello, world! public class Program { public static main(string[] argus){ System.out.println(“Hello, world!”); } } Java
  • 7. Hello, world! <html> <head> <title>PHP Test</title> </head> <body> <?php echo ‘<p>Hello, world!</p>’; ?> </body> </html> PHP
  • 8. Hello, world! print “Hello, world!” Python
  • 9. Operator • + • - • * • / • // • ** • % • == • != • > • < • >= • <= • += • -= • *= • /= • **= • //= • & • | • ^ • ~ • >> • << • and • or • not • in • is
  • 10. Variables •int i = 1 •float f = 2.1 •bool b = False •str s = ‘hi’ •list l = [1, 2, “hello again”, 4] •tuple t = (True, 2.1) •dict d = {1:”One”, 2:”Two”} •set s = {“some”, “unique”, “objects”}
  • 11. Variables - Assignment >>> dummy_variable = 2 >>> dummy_variable = ‘hi’ >>> a, b = 2, 3 >>> a, b = b, a int main() { int a = 2, b = 3 , k; k = a; a = b; b = a; return 0; } in c++
  • 12. Variables - Casting >>> float(1) 1.0 >>> str(1) ‘1’ >>> int(‘1’) 1 >>> list(1) [1, ] >>> list(‘hello’) ['h', 'e', 'l', 'l', ‘o'] >>> set([1, 0, 1, 1, 0, 1, 0, 0]) set([1, 0])
  • 13. String • concatenate • slice • find • replace • count • capitalize
  • 14. List • slice • concatenate • sort • append - pop - remove - insert
  • 17. Function • Keyword arguments • Default arguments • Functions are objects
  • 19. Object oriented • Event classes are object • Dynamically add attributes • Static methods and attributes • Property
  • 20. Beyond OO reflection/introspection • type(obj) • isinstance(obj, class) • issubclass(class, class) • getattr(obj, key) / hastattr(obj, key)
  • 21. First class functions • function assignment • send function as parameter • callable objects
  • 22. Strategy pattern 
 class Player: 
 def __init__(self, play_behavior): 
 self.play_behavior = play_behavior 
 
 def play(self): 
 return self.play_behavior 
 
 
 def attack(): 
 print("I attack”) 
 
 attacker = Player(attack) .
  • 23. Closure pattern • function in function def add(x): 
 def add2(y): 
 return x + y 
 return add2 or with lambda def add(x): 
 return lambda y: x+y • callable class Add: 
 def __init__(self, x): 
 self.x = x 
 
 def __call__(self, y): 
 return self.x + y 

  • 24. Generator pattern • subroutine vs co-routine 
 def get_primes(number): 
 while True: 
 if is_prime(number): 
 yield number 
 number += 1 
 
 def solve_number_10(): 
 total = 0 
 for next_prime in get_primes(2): 
 if next_prime < 2000000: 
 total += next_prime 
 else: 
 break 
 print(total)
  • 25. Decorator pattern def register_function(f): 
 print("%s function is registered" % f.__name__) 
 return f 
 
 
 @register_function 
 def do_dummy_stuff(): 
 return 1 

  • 26. Decorator pattern add some tricks def log(f): 
 def logger_function(*args, **kwargs): 
 result = f(*args, **kwargs) 
 print("Result: %s" % result) 
 return result 
 
 return logger_function 
 
 @log 
 def do_dummy_stuff(): 
 return 1
  • 27. Decorator pattern add some tricks def log(level=‘DEBUG'): 
 def decorator(f): 
 def logger_function(*args, **kwargs): 
 result = f(*args, **kwargs) 
 print("%s: %s" % (level, result)) 
 return result 
 
 return logger_function 
 
 return decorator 
 
 
 @log(level=‘INFO') 
 def do_dummy_stuff(): 
 return 1
  • 28. Complex syntax One-line if: print('even' if i % 2 == 0 else 'odd')
 One line for: l = [num ** 2 for num in numbers]
 None or … : value = dummy_function_may_return_none() or 0