SlideShare a Scribd company logo
1 of 21
Download to read offline
Introduction to Python
   A side-by-side comparison with Java




Tamer Mohammed Abdul-Radi
Backend Software Engineer at Cloud9ers ltd
  tamer_radi
  tamerradi
Python
Developed by Guido van Rossum during the
1989 Christmas holidays
Open source
Very readable
Programmer friendly
Python Versions
Python 2.7                                    Python 3.1
● Still widely used                           ● Present and Future
● Have an extended                              of the language
  support                                     ● Not backward
● Django, Twisted,                              compatible
  and PIL supports                            ● Limited library
  Python 2.x only                               support

    ●   Comparison was made on 31 May 2012, things may change later
    ●   There are two tools "2to3" and "3to2"' to convert scripts between versions
Python Tour
Compared to Java
Hello World
                 Java                                Python 2.7
public class Main {                          print "Hello World"
  public static void main(String[] args) {
     System.out.println("Hello World");
  }
}
                                                      Python 3.x
                                             print("Hello World")
Lists
                 Java                             Python
import java.util.Vector                       x = ['a', 'b', 'c', 'd']
public class Main {                           for item in x:
  public static void main(String[] args) {       print item
     Vector x = new Vector();
     x.addElement("a")
     x.addElement("b")
     x.addElement("c")
     x.addElement("d")
     for (int i = 0 ; i < x.length; i++) {
        System.out.println(x.elementAt(i));
     }
  }
}
Lists vs Arrays
           Java                        Python
             Array                        Array
int[] a = {1, 2, 3};           import array
System.out.println(a[0])       a = array.array('i',
a[0] = 55                      [1,2,3])
                               print a[0]
            List
                               a[0] = 55
List<Integer> a = new
       ArrayList<Integer>();                 List
a.add(new Integer(1))          a = [1,2,3]
System.out.println(a.get(0))   print a[0]
                               a[0] = 55
Hashtables
                 Java                        Python
import java.util.Hashtable                   x = {}
public class Main {                          x['a'] = 1
  public static void main(String[] args) {   print x['a']
     Hashtable x = new Hashtable();
     x.put("a", new Integer(1))
     System.out.println(x.get("a"));
                                                 OR
  }
                                             x = {'a' : 1}
}
                                             print x['a']
IO
                     Java                                      Python
public class Main {                                  f = open('file.txt', 'w')
  public static void main(String[] args) {           f.write('Hello World')
     try {                                           f.close()
        File f = new File('file.txt');
        PrintWriter ps = new PrintWriter(
                  new OutputStreamWriter(
                       new File OutputStream(f)));
                                                                  OR
        ps.print("Hello World")
     }
     catch (IOException e) {
                                                     with open('file.txt, 'w') as f:
        e.printStackTrace();
                                                          f.write('Hello World')
     }
  }
}
Classes
                      Java                            Python
public class Point {                         class Point():
  public int x;                                 def __init__(self, x, y) {
  public int y;                                   self.x = x
  public MyClass(int x, int y) {                  self.y = y
     this.x = x                                 }
     this.y = y                              p = Point(1, 2)
  }
  public static void main(String[] args) {
     p = new Point(1, 2)
  }
}
Interesting Features
in Python Programming Language
Introspection

The ability to examine something to determine
● what it is
● what it knows
● what it is capable of doing
Introspection gives programmers a great deal
of flexibility and control.



Source: http://www.ibm.com/developerworks/library/l-pyint/index.html
Syntactic Sugar for very high level
            data structures
Lists                         Tuples
l = ['a', 'b', 'c', 'd']      t = ('a', 'b', 'c', 'd')
print l[0]                    print t[0]
l[0] = 'z'
                              Strings
Hashtables                    s = 'abcd'
d = {0:'a', 100:'b', 5:'c'}   print s[0]
print d[0]
d['strings_too'] = 'z'        Sets
                              s = {0, 1, 2, 3}
Enhanced For
for item in l:
   print item

for char in s:    There is no special type for
                  chars; A char in python is
   print char
                  string with length equals one

for item in t:
   print item
Enhanced For
for key in d:
   print key

for value in d.values():
   print value

for key, value in d.items():
   print key, value
Positional & Keyword Arguments
def my_function(a, b, c, d):
  print a, b, c, d

my_function(1, 2, 3, 4)
my_function(a=1, b=2, c=3, d=4)
my_function(1, b=2, c=3, d=4)
my_function(1, 2, c=3, d=4)
my_function(1, 2, d=4, c=3)
OOP
● Everything is an object
● No Primitives, integers are objects
● Functions are objects,
  ○ you can send a function as parameter to another
    function
  ○ you can have a list of functions
● Classes are objects!
Things you can kiss goodbye
●   Curly Braces to define Blocks
●   Semicolons (optional)
●   Switch case
●   Classic For Loops
●   Interfaces
●   Checked Exceptions
Things you won't miss in Python
●   Simplicity
●   Readability
●   True OOP
●   Fun!
Things Python sucks at
● Lots of mathematical computations
You can write the computation code in C ,or
C++ and call it from Python!

● Using multithreading with mutli-cores or CPUs
You can multiprocessing rather than multi-
threading
What is Python good for?
● String processing (regular expressions, Unicode,
    calculating differences between files)
●   Internet protocols (HTTP, FTP, SMTP, XML-RPC, POP,
    IMAP, CGI programming)
●   Software engineering (unit testing, logging, profiling,
    parsing Python code)
●   Operating system interfaces (system calls, file systems,
    TCP/IP sockets)

More Related Content

What's hot

Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)intelliyole
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Introthnetos
 
Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13Jay Coskey
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance PythonIan Ozsvald
 
6. Generics. Collections. Streams
6. Generics. Collections. Streams6. Generics. Collections. Streams
6. Generics. Collections. StreamsDEVTYPE
 
Introduction to Python and TensorFlow
Introduction to Python and TensorFlowIntroduction to Python and TensorFlow
Introduction to Python and TensorFlowBayu Aldi Yansyah
 
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 minutesSumit Raj
 
Tcl2012 8.6 Changes
Tcl2012 8.6 ChangesTcl2012 8.6 Changes
Tcl2012 8.6 Changeshobbs
 
Clojure: The Art of Abstraction
Clojure: The Art of AbstractionClojure: The Art of Abstraction
Clojure: The Art of AbstractionAlex Miller
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в JavaDEVTYPE
 
Python 표준 라이브러리
Python 표준 라이브러리Python 표준 라이브러리
Python 표준 라이브러리용 최
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobikrmboya
 
Intro to Functions Python
Intro to Functions PythonIntro to Functions Python
Intro to Functions Pythonprimeteacher32
 
Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!Kel Cecil
 
Python Training Tutorial for Frreshers
Python Training Tutorial for FrreshersPython Training Tutorial for Frreshers
Python Training Tutorial for Frreshersrajkamaltibacademy
 

What's hot (20)

Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
 
6. Generics. Collections. Streams
6. Generics. Collections. Streams6. Generics. Collections. Streams
6. Generics. Collections. Streams
 
Introduction to Python and TensorFlow
Introduction to Python and TensorFlowIntroduction to Python and TensorFlow
Introduction to Python and TensorFlow
 
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
 
Tcl2012 8.6 Changes
Tcl2012 8.6 ChangesTcl2012 8.6 Changes
Tcl2012 8.6 Changes
 
Comparing JVM languages
Comparing JVM languagesComparing JVM languages
Comparing JVM languages
 
Biopython: Overview, State of the Art and Outlook
Biopython: Overview, State of the Art and OutlookBiopython: Overview, State of the Art and Outlook
Biopython: Overview, State of the Art and Outlook
 
Clojure: The Art of Abstraction
Clojure: The Art of AbstractionClojure: The Art of Abstraction
Clojure: The Art of Abstraction
 
Initial Java Core Concept
Initial Java Core ConceptInitial Java Core Concept
Initial Java Core Concept
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
 
Python 표준 라이브러리
Python 표준 라이브러리Python 표준 라이브러리
Python 표준 라이브러리
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
 
Python in 90 minutes
Python in 90 minutesPython in 90 minutes
Python in 90 minutes
 
Intro to Functions Python
Intro to Functions PythonIntro to Functions Python
Intro to Functions Python
 
Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!
 
Python Training Tutorial for Frreshers
Python Training Tutorial for FrreshersPython Training Tutorial for Frreshers
Python Training Tutorial for Frreshers
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
 

Viewers also liked

Deploy Linux servers at scale
Deploy Linux servers at scaleDeploy Linux servers at scale
Deploy Linux servers at scaleEslam El Husseiny
 
Object-oriented Programming in Python
Object-oriented Programming in PythonObject-oriented Programming in Python
Object-oriented Programming in PythonJuan-Manuel Gimeno
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming LanguageLaxman Puri
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in PythonSujith Kumar
 
Introduction to python for Beginners
Introduction to python for Beginners Introduction to python for Beginners
Introduction to python for Beginners Sujith Kumar
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesMatt Harrison
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 

Viewers also liked (17)

wanna be h4ck3r !
wanna be h4ck3r !wanna be h4ck3r !
wanna be h4ck3r !
 
Mahmoud_Alshinhab_RHCSA
Mahmoud_Alshinhab_RHCSAMahmoud_Alshinhab_RHCSA
Mahmoud_Alshinhab_RHCSA
 
Citrix Cloud Platform
Citrix Cloud PlatformCitrix Cloud Platform
Citrix Cloud Platform
 
Deploy Linux servers at scale
Deploy Linux servers at scaleDeploy Linux servers at scale
Deploy Linux servers at scale
 
Playing with Scala
Playing with ScalaPlaying with Scala
Playing with Scala
 
Dev ops
Dev opsDev ops
Dev ops
 
Testing puppet
Testing puppetTesting puppet
Testing puppet
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Object-oriented Programming in Python
Object-oriented Programming in PythonObject-oriented Programming in Python
Object-oriented Programming in Python
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in Python
 
Introduction to python for Beginners
Introduction to python for Beginners Introduction to python for Beginners
Introduction to python for Beginners
 
Python Presentation
Python PresentationPython Presentation
Python Presentation
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Similar to Python tour

Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Edureka!
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarROHIT JAISWAR
 
Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Yuren Ju
 
Python-GTK
Python-GTKPython-GTK
Python-GTKYuren Ju
 
Python For Scientists
Python For ScientistsPython For Scientists
Python For Scientistsaeberspaecher
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical FileSoumya Behera
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streamsShahjahan Samoon
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayUtkarsh Sengar
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101Ankur Gupta
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIjagriti srivastava
 
PPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.TechPPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.Techssuser2678ab
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)Alok Kumar
 
Python summer course play with python (lab1)
Python summer course  play with python  (lab1)Python summer course  play with python  (lab1)
Python summer course play with python (lab1)iloveallahsomuch
 
Python summer course play with python (lab1)
Python summer course  play with python  (lab1)Python summer course  play with python  (lab1)
Python summer course play with python (lab1)iloveallahsomuch
 

Similar to Python tour (20)

Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
 
Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Python GTK (Hacking Camp)
Python GTK (Hacking Camp)
 
Python-GTK
Python-GTKPython-GTK
Python-GTK
 
Lezione03
Lezione03Lezione03
Lezione03
 
Lezione03
Lezione03Lezione03
Lezione03
 
Python For Scientists
Python For ScientistsPython For Scientists
Python For Scientists
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time API
 
Scala
ScalaScala
Scala
 
PPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.TechPPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.Tech
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
 
Python summer course play with python (lab1)
Python summer course  play with python  (lab1)Python summer course  play with python  (lab1)
Python summer course play with python (lab1)
 
Python summer course play with python (lab1)
Python summer course  play with python  (lab1)Python summer course  play with python  (lab1)
Python summer course play with python (lab1)
 
Nabil code
Nabil  codeNabil  code
Nabil code
 
Nabil code
Nabil  codeNabil  code
Nabil code
 
Nabil code
Nabil  codeNabil  code
Nabil code
 

Recently uploaded

定制(UofT毕业证书)加拿大多伦多大学毕业证成绩单原版一比一
定制(UofT毕业证书)加拿大多伦多大学毕业证成绩单原版一比一定制(UofT毕业证书)加拿大多伦多大学毕业证成绩单原版一比一
定制(UofT毕业证书)加拿大多伦多大学毕业证成绩单原版一比一lvtagr7
 
8377087607 Full Enjoy @24/7 Call Girls in Patel Nagar Delhi NCR
8377087607 Full Enjoy @24/7 Call Girls in Patel Nagar Delhi NCR8377087607 Full Enjoy @24/7 Call Girls in Patel Nagar Delhi NCR
8377087607 Full Enjoy @24/7 Call Girls in Patel Nagar Delhi NCRdollysharma2066
 
Air-Hostess Call Girls Shobhabazar | 8250192130 At Low Cost Cash Payment Booking
Air-Hostess Call Girls Shobhabazar | 8250192130 At Low Cost Cash Payment BookingAir-Hostess Call Girls Shobhabazar | 8250192130 At Low Cost Cash Payment Booking
Air-Hostess Call Girls Shobhabazar | 8250192130 At Low Cost Cash Payment BookingRiya Pathan
 
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...Riya Pathan
 
Private Call Girls Bansdroni - 8250192130 | 24x7 Service Available Near Me
Private Call Girls Bansdroni - 8250192130 | 24x7 Service Available Near MePrivate Call Girls Bansdroni - 8250192130 | 24x7 Service Available Near Me
Private Call Girls Bansdroni - 8250192130 | 24x7 Service Available Near MeRiya Pathan
 
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call GirlFun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call GirlApsara Of India
 
VIP Call Girls In Goa 7028418221 Call Girls In Baga Beach Escorts Service
VIP Call Girls In Goa 7028418221 Call Girls In Baga Beach Escorts ServiceVIP Call Girls In Goa 7028418221 Call Girls In Baga Beach Escorts Service
VIP Call Girls In Goa 7028418221 Call Girls In Baga Beach Escorts ServiceApsara Of India
 
LE IMPOSSIBRU QUIZ (Based on Splapp-me-do)
LE IMPOSSIBRU QUIZ (Based on Splapp-me-do)LE IMPOSSIBRU QUIZ (Based on Splapp-me-do)
LE IMPOSSIBRU QUIZ (Based on Splapp-me-do)bertfelixtorre
 
Gripping Adult Web Series You Can't Afford to Miss
Gripping Adult Web Series You Can't Afford to MissGripping Adult Web Series You Can't Afford to Miss
Gripping Adult Web Series You Can't Afford to Missget joys
 
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7Riya Pathan
 
Hifi Laxmi Nagar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ D...
Hifi Laxmi Nagar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ D...Hifi Laxmi Nagar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ D...
Hifi Laxmi Nagar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ D...srsj9000
 
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal EscortsCall Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal EscortsApsara Of India
 
High Profile Call Girls Sodepur - 8250192130 Escorts Service with Real Photos...
High Profile Call Girls Sodepur - 8250192130 Escorts Service with Real Photos...High Profile Call Girls Sodepur - 8250192130 Escorts Service with Real Photos...
High Profile Call Girls Sodepur - 8250192130 Escorts Service with Real Photos...Riya Pathan
 
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts ServiceVip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts ServiceApsara Of India
 
The Fine Line Between Honest and Evil Comics by Salty Vixen
The Fine Line Between Honest and Evil Comics by Salty VixenThe Fine Line Between Honest and Evil Comics by Salty Vixen
The Fine Line Between Honest and Evil Comics by Salty VixenSalty Vixen Stories & More
 
Authentic No 1 Amil Baba In Pakistan Authentic No 1 Amil Baba In Karachi No 1...
Authentic No 1 Amil Baba In Pakistan Authentic No 1 Amil Baba In Karachi No 1...Authentic No 1 Amil Baba In Pakistan Authentic No 1 Amil Baba In Karachi No 1...
Authentic No 1 Amil Baba In Pakistan Authentic No 1 Amil Baba In Karachi No 1...First NO1 World Amil baba in Faisalabad
 
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...Amil Baba Company
 
Call Girls Delhi {Safdarjung} 9711199012 high profile service
Call Girls Delhi {Safdarjung} 9711199012 high profile serviceCall Girls Delhi {Safdarjung} 9711199012 high profile service
Call Girls Delhi {Safdarjung} 9711199012 high profile servicerehmti665
 
Call Girls Near Taurus Sarovar Portico Hotel New Delhi 9873777170
Call Girls Near Taurus Sarovar Portico Hotel New Delhi 9873777170Call Girls Near Taurus Sarovar Portico Hotel New Delhi 9873777170
Call Girls Near Taurus Sarovar Portico Hotel New Delhi 9873777170Sonam Pathan
 

Recently uploaded (20)

定制(UofT毕业证书)加拿大多伦多大学毕业证成绩单原版一比一
定制(UofT毕业证书)加拿大多伦多大学毕业证成绩单原版一比一定制(UofT毕业证书)加拿大多伦多大学毕业证成绩单原版一比一
定制(UofT毕业证书)加拿大多伦多大学毕业证成绩单原版一比一
 
8377087607 Full Enjoy @24/7 Call Girls in Patel Nagar Delhi NCR
8377087607 Full Enjoy @24/7 Call Girls in Patel Nagar Delhi NCR8377087607 Full Enjoy @24/7 Call Girls in Patel Nagar Delhi NCR
8377087607 Full Enjoy @24/7 Call Girls in Patel Nagar Delhi NCR
 
Air-Hostess Call Girls Shobhabazar | 8250192130 At Low Cost Cash Payment Booking
Air-Hostess Call Girls Shobhabazar | 8250192130 At Low Cost Cash Payment BookingAir-Hostess Call Girls Shobhabazar | 8250192130 At Low Cost Cash Payment Booking
Air-Hostess Call Girls Shobhabazar | 8250192130 At Low Cost Cash Payment Booking
 
young call girls in Hari Nagar,🔝 9953056974 🔝 escort Service
young call girls in Hari Nagar,🔝 9953056974 🔝 escort Serviceyoung call girls in Hari Nagar,🔝 9953056974 🔝 escort Service
young call girls in Hari Nagar,🔝 9953056974 🔝 escort Service
 
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
 
Private Call Girls Bansdroni - 8250192130 | 24x7 Service Available Near Me
Private Call Girls Bansdroni - 8250192130 | 24x7 Service Available Near MePrivate Call Girls Bansdroni - 8250192130 | 24x7 Service Available Near Me
Private Call Girls Bansdroni - 8250192130 | 24x7 Service Available Near Me
 
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call GirlFun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
 
VIP Call Girls In Goa 7028418221 Call Girls In Baga Beach Escorts Service
VIP Call Girls In Goa 7028418221 Call Girls In Baga Beach Escorts ServiceVIP Call Girls In Goa 7028418221 Call Girls In Baga Beach Escorts Service
VIP Call Girls In Goa 7028418221 Call Girls In Baga Beach Escorts Service
 
LE IMPOSSIBRU QUIZ (Based on Splapp-me-do)
LE IMPOSSIBRU QUIZ (Based on Splapp-me-do)LE IMPOSSIBRU QUIZ (Based on Splapp-me-do)
LE IMPOSSIBRU QUIZ (Based on Splapp-me-do)
 
Gripping Adult Web Series You Can't Afford to Miss
Gripping Adult Web Series You Can't Afford to MissGripping Adult Web Series You Can't Afford to Miss
Gripping Adult Web Series You Can't Afford to Miss
 
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
 
Hifi Laxmi Nagar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ D...
Hifi Laxmi Nagar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ D...Hifi Laxmi Nagar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ D...
Hifi Laxmi Nagar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ D...
 
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal EscortsCall Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
 
High Profile Call Girls Sodepur - 8250192130 Escorts Service with Real Photos...
High Profile Call Girls Sodepur - 8250192130 Escorts Service with Real Photos...High Profile Call Girls Sodepur - 8250192130 Escorts Service with Real Photos...
High Profile Call Girls Sodepur - 8250192130 Escorts Service with Real Photos...
 
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts ServiceVip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
 
The Fine Line Between Honest and Evil Comics by Salty Vixen
The Fine Line Between Honest and Evil Comics by Salty VixenThe Fine Line Between Honest and Evil Comics by Salty Vixen
The Fine Line Between Honest and Evil Comics by Salty Vixen
 
Authentic No 1 Amil Baba In Pakistan Authentic No 1 Amil Baba In Karachi No 1...
Authentic No 1 Amil Baba In Pakistan Authentic No 1 Amil Baba In Karachi No 1...Authentic No 1 Amil Baba In Pakistan Authentic No 1 Amil Baba In Karachi No 1...
Authentic No 1 Amil Baba In Pakistan Authentic No 1 Amil Baba In Karachi No 1...
 
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
 
Call Girls Delhi {Safdarjung} 9711199012 high profile service
Call Girls Delhi {Safdarjung} 9711199012 high profile serviceCall Girls Delhi {Safdarjung} 9711199012 high profile service
Call Girls Delhi {Safdarjung} 9711199012 high profile service
 
Call Girls Near Taurus Sarovar Portico Hotel New Delhi 9873777170
Call Girls Near Taurus Sarovar Portico Hotel New Delhi 9873777170Call Girls Near Taurus Sarovar Portico Hotel New Delhi 9873777170
Call Girls Near Taurus Sarovar Portico Hotel New Delhi 9873777170
 

Python tour

  • 1. Introduction to Python A side-by-side comparison with Java Tamer Mohammed Abdul-Radi Backend Software Engineer at Cloud9ers ltd tamer_radi tamerradi
  • 2. Python Developed by Guido van Rossum during the 1989 Christmas holidays Open source Very readable Programmer friendly
  • 3. Python Versions Python 2.7 Python 3.1 ● Still widely used ● Present and Future ● Have an extended of the language support ● Not backward ● Django, Twisted, compatible and PIL supports ● Limited library Python 2.x only support ● Comparison was made on 31 May 2012, things may change later ● There are two tools "2to3" and "3to2"' to convert scripts between versions
  • 5. Hello World Java Python 2.7 public class Main { print "Hello World" public static void main(String[] args) { System.out.println("Hello World"); } } Python 3.x print("Hello World")
  • 6. Lists Java Python import java.util.Vector x = ['a', 'b', 'c', 'd'] public class Main { for item in x: public static void main(String[] args) { print item Vector x = new Vector(); x.addElement("a") x.addElement("b") x.addElement("c") x.addElement("d") for (int i = 0 ; i < x.length; i++) { System.out.println(x.elementAt(i)); } } }
  • 7. Lists vs Arrays Java Python Array Array int[] a = {1, 2, 3}; import array System.out.println(a[0]) a = array.array('i', a[0] = 55 [1,2,3]) print a[0] List a[0] = 55 List<Integer> a = new ArrayList<Integer>(); List a.add(new Integer(1)) a = [1,2,3] System.out.println(a.get(0)) print a[0] a[0] = 55
  • 8. Hashtables Java Python import java.util.Hashtable x = {} public class Main { x['a'] = 1 public static void main(String[] args) { print x['a'] Hashtable x = new Hashtable(); x.put("a", new Integer(1)) System.out.println(x.get("a")); OR } x = {'a' : 1} } print x['a']
  • 9. IO Java Python public class Main { f = open('file.txt', 'w') public static void main(String[] args) { f.write('Hello World') try { f.close() File f = new File('file.txt'); PrintWriter ps = new PrintWriter( new OutputStreamWriter( new File OutputStream(f))); OR ps.print("Hello World") } catch (IOException e) { with open('file.txt, 'w') as f: e.printStackTrace(); f.write('Hello World') } } }
  • 10. Classes Java Python public class Point { class Point(): public int x; def __init__(self, x, y) { public int y; self.x = x public MyClass(int x, int y) { self.y = y this.x = x } this.y = y p = Point(1, 2) } public static void main(String[] args) { p = new Point(1, 2) } }
  • 11. Interesting Features in Python Programming Language
  • 12. Introspection The ability to examine something to determine ● what it is ● what it knows ● what it is capable of doing Introspection gives programmers a great deal of flexibility and control. Source: http://www.ibm.com/developerworks/library/l-pyint/index.html
  • 13. Syntactic Sugar for very high level data structures Lists Tuples l = ['a', 'b', 'c', 'd'] t = ('a', 'b', 'c', 'd') print l[0] print t[0] l[0] = 'z' Strings Hashtables s = 'abcd' d = {0:'a', 100:'b', 5:'c'} print s[0] print d[0] d['strings_too'] = 'z' Sets s = {0, 1, 2, 3}
  • 14. Enhanced For for item in l: print item for char in s: There is no special type for chars; A char in python is print char string with length equals one for item in t: print item
  • 15. Enhanced For for key in d: print key for value in d.values(): print value for key, value in d.items(): print key, value
  • 16. Positional & Keyword Arguments def my_function(a, b, c, d): print a, b, c, d my_function(1, 2, 3, 4) my_function(a=1, b=2, c=3, d=4) my_function(1, b=2, c=3, d=4) my_function(1, 2, c=3, d=4) my_function(1, 2, d=4, c=3)
  • 17. OOP ● Everything is an object ● No Primitives, integers are objects ● Functions are objects, ○ you can send a function as parameter to another function ○ you can have a list of functions ● Classes are objects!
  • 18. Things you can kiss goodbye ● Curly Braces to define Blocks ● Semicolons (optional) ● Switch case ● Classic For Loops ● Interfaces ● Checked Exceptions
  • 19. Things you won't miss in Python ● Simplicity ● Readability ● True OOP ● Fun!
  • 20. Things Python sucks at ● Lots of mathematical computations You can write the computation code in C ,or C++ and call it from Python! ● Using multithreading with mutli-cores or CPUs You can multiprocessing rather than multi- threading
  • 21. What is Python good for? ● String processing (regular expressions, Unicode, calculating differences between files) ● Internet protocols (HTTP, FTP, SMTP, XML-RPC, POP, IMAP, CGI programming) ● Software engineering (unit testing, logging, profiling, parsing Python code) ● Operating system interfaces (system calls, file systems, TCP/IP sockets)