SlideShare a Scribd company logo
1 of 24
Download to read offline
Shabda Raaj
   This is a workshop, not a talk.
   You are expected to code along.
   So pull out your laptops.
   Install python, ipython and komodo edit. (Or
    editor of your choice.)
   Assume that you know programming in any
    language.
   So we don’t spend a lot of time explaining
    basics.
   BUT, stop and ask if something doesn't make
    sense.
   AND Definitely Stop me if I am going too
    slow, too fast, or making no sense.
   Dynamically but strongly typed.
   Very object oriented - everything is an object.
   But pragmatic - Objects aren't everthing.
   Allows various paradigms of programming -
    OO, procedural, functional.
   Shallow learning curve, but powerful powerful
    capabilities available, when you need them.
   import this
   We will come back to this slide.
   Hello world
   >>> print "Hello World"
   for, while, if, else, break, continue
       -Yeah they are available, surprised?
   We will use them in a moment, but after we
    see the data structures available.
   List - Like ArrayList in Java
   Tuple - Like List, but immutable
   Dict - Like Hashmaps in Java
   For Loop
           for el in iterable:
              [block statement]
       the classic for loop
           for (int i; i < n; i++){}
           for i in range(n):
              #Work with I
           While condition:
              [block]
   break, continue. Normal operation - break out of
    current loop.
   If: elif: else:

    if condition:
        [block]
     else:
        [block]
   You have enough information now to write a
    solution
   Problem statement:
   Write a program that prints the numbers from
    1 to 100. But for multiples of three print "Fizz"
    instead of the number and for the multiples of
    five print "Buzz". For numbers which are
    multiples of both three and five print
    "FizzBuzz".
   def function_name(argument_list):
            [block]
   Functions can have default value.
          def fizzbuzz(till=100, fizz='fizz', buzz='buzz'):
            #fi zzbuzz code
   Functions can have variable length values.
          ex multiply all values passed to a function.
   Functions are first class - They are objects too.
    They can be passed to other
   functions, assigned to variables etc.
   class ClassName(base_classes):
          [block]
   Classes are first class too
   They can be passed to function, and assigned
    to variables.
   If we list all the natural numbers below 10 that
    are multiples of 3 or 5, we get 3, 5, 6 and 9.
    The sum of these multiples is 23.
   Find the sum of all the multiples of 3 or 5
    below 1000
   The last solution was needlessly verbose
   List comprehension: Take a list and transform it.
   Standard list comprehension syntax - [expr(i) for i
    in iterable if condition]
   List of all squares: [i*i for i in range(1,11)]
   List of all squares of even numbers: [i*i for i in
    range(1,11) if i%2 == 0]
   So solution to last problem is just
   sum([i*i for i in range(1,1001) if i%3 == 0 or
    i%5==0])
   List comprehensions are python way to do
    functional programming constructs
   [function(i) for i in iterable if condition] is
    filter(func2, map(func1, iter))
   Lets see how this list comprehension maps to
    functional concepts
   Get the list of squares of even numbers
   Open a file with - open('location') or
    file('location')
   or give a mode - open('location', 'rw')
   iterate as
          for line in open_file.readlines():
                   print line #Or whatever
   or
   string = open_file.read()
   Find the most commonly used word in the
    Alice in wonderland text.
   Batteries included
       math
       datetime
       string
       re
       random
       os
       pickle
   Do a dir() and see for yourself.
   And a lot, lot more: http://docs.python.org/library/
   Dynamically but strongly typed.
   Very object oriented - everything is an object.
   But pragmatic - Objects aren't everything.
   Allows various paradigms of programming -
    OO, procedural, functional.
   Shallow learning curve, but powerful powerful
    capabilities available, when you need them.
   import this
   Syntacting sugar for
       foo_func =docorator_func(foo_func)
   Many useful frameworks
       Tornado,
       Pylons,
       Turbogears
       Django
       GAE
   Django: Most actively developed and largest
    community participation
   PIL
   Mechanize
   Beautiful Soup
   Element Tree
   python.org
   diveintopython.org
   uswaretech.com/blog
   Thank You.
   You can give feedback, ask questions at
    shabda@uswaretech.com

More Related Content

What's hot

Real World Haskell: Lecture 6
Real World Haskell: Lecture 6Real World Haskell: Lecture 6
Real World Haskell: Lecture 6
Bryan O'Sullivan
 

What's hot (20)

A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp language
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Python basic
Python basicPython basic
Python basic
 
Advance python
Advance pythonAdvance python
Advance python
 
Chapter 5 - THREADING & REGULAR exp - MAULIK BORSANIYA
Chapter 5 - THREADING & REGULAR exp - MAULIK BORSANIYAChapter 5 - THREADING & REGULAR exp - MAULIK BORSANIYA
Chapter 5 - THREADING & REGULAR exp - MAULIK BORSANIYA
 
Os Goodger
Os GoodgerOs Goodger
Os Goodger
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
 
Python Basics
Python Basics Python Basics
Python Basics
 
Tackling repetitive tasks with serial or parallel programming in R
Tackling repetitive tasks with serial or parallel programming in RTackling repetitive tasks with serial or parallel programming in R
Tackling repetitive tasks with serial or parallel programming in R
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
Python
PythonPython
Python
 
Chapter 7 String
Chapter 7 StringChapter 7 String
Chapter 7 String
 
Python tuple
Python   tuplePython   tuple
Python tuple
 
Real World Haskell: Lecture 6
Real World Haskell: Lecture 6Real World Haskell: Lecture 6
Real World Haskell: Lecture 6
 
Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Two
 
Lisp
LispLisp
Lisp
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talk
 
python codes
python codespython codes
python codes
 

Similar to Beginning Python

Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)
Ralf Laemmel
 
Haskell retrospective
Haskell retrospectiveHaskell retrospective
Haskell retrospective
chenge2k
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
priestmanmable
 

Similar to Beginning Python (20)

Beginning Python
Beginning PythonBeginning Python
Beginning Python
 
Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)
 
Python Session - 4
Python Session - 4Python Session - 4
Python Session - 4
 
Improve Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptxImprove Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptx
 
Brogramming - Python, Bash for Data Processing, and Git
Brogramming - Python, Bash for Data Processing, and GitBrogramming - Python, Bash for Data Processing, and Git
Brogramming - Python, Bash for Data Processing, and Git
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Erlang session1
Erlang session1Erlang session1
Erlang session1
 
Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional Programming
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
 
How to use tensorflow
How to use tensorflowHow to use tensorflow
How to use tensorflow
 
Haskell retrospective
Haskell retrospectiveHaskell retrospective
Haskell retrospective
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Code Like Pythonista
Code Like PythonistaCode Like Pythonista
Code Like Pythonista
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
 
Natural language processing open seminar For Tensorflow usage
Natural language processing open seminar For Tensorflow usageNatural language processing open seminar For Tensorflow usage
Natural language processing open seminar For Tensorflow usage
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin Odersky
 

More from Agiliq Info Solutions India Pvt Ltd (6)

Rails for Django developers
Rails for Django developersRails for Django developers
Rails for Django developers
 
Lbs apps-monetization
Lbs apps-monetizationLbs apps-monetization
Lbs apps-monetization
 
Python Metaclass and How Django uses them: Foss 2010
Python Metaclass and How Django uses them: Foss 2010Python Metaclass and How Django uses them: Foss 2010
Python Metaclass and How Django uses them: Foss 2010
 
Django design-patterns
Django design-patternsDjango design-patterns
Django design-patterns
 
The django quiz
The django quizThe django quiz
The django quiz
 
How to launch a startup
How to launch a startupHow to launch a startup
How to launch a startup
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Beginning Python

  • 2. This is a workshop, not a talk.  You are expected to code along.  So pull out your laptops.  Install python, ipython and komodo edit. (Or editor of your choice.)
  • 3. Assume that you know programming in any language.  So we don’t spend a lot of time explaining basics.  BUT, stop and ask if something doesn't make sense.  AND Definitely Stop me if I am going too slow, too fast, or making no sense.
  • 4. Dynamically but strongly typed.  Very object oriented - everything is an object.  But pragmatic - Objects aren't everthing.  Allows various paradigms of programming - OO, procedural, functional.  Shallow learning curve, but powerful powerful capabilities available, when you need them.  import this  We will come back to this slide.
  • 5. Hello world  >>> print "Hello World"
  • 6. for, while, if, else, break, continue  -Yeah they are available, surprised?  We will use them in a moment, but after we see the data structures available.
  • 7. List - Like ArrayList in Java  Tuple - Like List, but immutable  Dict - Like Hashmaps in Java
  • 8. For Loop  for el in iterable:  [block statement]  the classic for loop  for (int i; i < n; i++){}  for i in range(n):  #Work with I  While condition:  [block]  break, continue. Normal operation - break out of current loop.
  • 9. If: elif: else:  if condition:  [block]  else:  [block]
  • 10. You have enough information now to write a solution  Problem statement:  Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
  • 11. def function_name(argument_list):  [block]  Functions can have default value.  def fizzbuzz(till=100, fizz='fizz', buzz='buzz'):  #fi zzbuzz code  Functions can have variable length values.  ex multiply all values passed to a function.  Functions are first class - They are objects too. They can be passed to other  functions, assigned to variables etc.
  • 12. class ClassName(base_classes):  [block]  Classes are first class too  They can be passed to function, and assigned to variables.
  • 13. If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.  Find the sum of all the multiples of 3 or 5 below 1000
  • 14. The last solution was needlessly verbose  List comprehension: Take a list and transform it.  Standard list comprehension syntax - [expr(i) for i in iterable if condition]  List of all squares: [i*i for i in range(1,11)]  List of all squares of even numbers: [i*i for i in range(1,11) if i%2 == 0]  So solution to last problem is just  sum([i*i for i in range(1,1001) if i%3 == 0 or i%5==0])
  • 15. List comprehensions are python way to do functional programming constructs  [function(i) for i in iterable if condition] is filter(func2, map(func1, iter))  Lets see how this list comprehension maps to functional concepts  Get the list of squares of even numbers
  • 16. Open a file with - open('location') or file('location')  or give a mode - open('location', 'rw')  iterate as  for line in open_file.readlines():  print line #Or whatever  or  string = open_file.read()
  • 17. Find the most commonly used word in the Alice in wonderland text.
  • 18. Batteries included  math  datetime  string  re  random  os  pickle  Do a dir() and see for yourself.  And a lot, lot more: http://docs.python.org/library/
  • 19. Dynamically but strongly typed.  Very object oriented - everything is an object.  But pragmatic - Objects aren't everything.  Allows various paradigms of programming - OO, procedural, functional.  Shallow learning curve, but powerful powerful capabilities available, when you need them.  import this
  • 20. Syntacting sugar for  foo_func =docorator_func(foo_func)
  • 21. Many useful frameworks  Tornado,  Pylons,  Turbogears  Django  GAE  Django: Most actively developed and largest community participation
  • 22. PIL  Mechanize  Beautiful Soup  Element Tree
  • 23. python.org  diveintopython.org  uswaretech.com/blog
  • 24. Thank You.  You can give feedback, ask questions at shabda@uswaretech.com