SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
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?

Más contenido relacionado

La actualidad más candente

Learn python in 20 minutes
Learn python in 20 minutesLearn python in 20 minutes
Learn python in 20 minutesSidharth Nadhan
 
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 PythonSumit 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 beginnersKálmán "KAMI" Szalai
 
Python: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersPython: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersGlenn De Backer
 
Python language data types
Python language data typesPython language data types
Python language data typesHoang 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 ZakharenkoNina Zakharenko
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAhmed Salama
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In PythonMarwan 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 LibrarySantosh 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-2RajKumar Rampelli
 

La actualidad más candente (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
 

Destacado

تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانیتست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانیirpycon
 
Apache spark session
Apache spark sessionApache spark session
Apache spark sessionknowbigdata
 
Concurrency and scalability with akka
Concurrency and scalability  with akkaConcurrency and scalability  with akka
Concurrency and scalability with akkaBardia Heydari
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming LanguageTahani 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 PythonTariq Rashid
 

Destacado (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 a Python in 90 minutes

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 islandAngela Byron
 
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 GolangChris McEniry
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsHermes 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 iOSMadhava 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 JavaCharles Nutter
 
Intro to kotlin 2018
Intro to kotlin 2018Intro to kotlin 2018
Intro to kotlin 2018Shady Selim
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDCMike Dirolf
 
Python Novice to Ninja
Python Novice to NinjaPython Novice to Ninja
Python Novice to NinjaAl 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 managementLaurent Leturgez
 
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 MaintainabilityMosky Liu
 

Similar a 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
 

Último

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 

Último (20)

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 

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