SlideShare a Scribd company logo
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 (20)

PDF
Are we ready to Go?
Adam Dudczak
 
PDF
Python opcodes
alexgolec
 
PDF
4. Обработка ошибок, исключения, отладка
DEVTYPE
 
PPTX
Dts x dicoding #2 memulai pemrograman kotlin
Ahmad Arif Faizin
 
PDF
Introducción a Elixir
Svet Ivantchev
 
PDF
Functional Algebra: Monoids Applied
Susan Potter
 
PPTX
Type Driven Development with TypeScript
Garth Gilmour
 
PDF
Design Pattern Observations
Dmitri Nesteruk
 
PPTX
Python
Wei-Bo Chen
 
PDF
C++ L05-Functions
Mohammad Shaker
 
PDF
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
John De Goes
 
PPTX
13 Strings and Text Processing
Intro C# Book
 
PPT
OOP Core Concept
Rays Technologies
 
PDF
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
PDF
The best language in the world
David Muñoz Díaz
 
PDF
Being functional in PHP (PHPDay Italy 2016)
David de Boer
 
PDF
Functional Programming Patterns (BuildStuff '14)
Scott Wlaschin
 
PDF
T3chFest 2016 - The polyglot programmer
David Muñoz Díaz
 
PPSX
Tuga IT 2017 - What's new in C# 7
Paulo Morgado
 
PPSX
What's New In C# 7
Paulo Morgado
 
Are we ready to Go?
Adam Dudczak
 
Python opcodes
alexgolec
 
4. Обработка ошибок, исключения, отладка
DEVTYPE
 
Dts x dicoding #2 memulai pemrograman kotlin
Ahmad Arif Faizin
 
Introducción a Elixir
Svet Ivantchev
 
Functional Algebra: Monoids Applied
Susan Potter
 
Type Driven Development with TypeScript
Garth Gilmour
 
Design Pattern Observations
Dmitri Nesteruk
 
Python
Wei-Bo Chen
 
C++ L05-Functions
Mohammad Shaker
 
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
John De Goes
 
13 Strings and Text Processing
Intro C# Book
 
OOP Core Concept
Rays Technologies
 
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
The best language in the world
David Muñoz Díaz
 
Being functional in PHP (PHPDay Italy 2016)
David de Boer
 
Functional Programming Patterns (BuildStuff '14)
Scott Wlaschin
 
T3chFest 2016 - The polyglot programmer
David Muñoz Díaz
 
Tuga IT 2017 - What's new in C# 7
Paulo Morgado
 
What's New In C# 7
Paulo Morgado
 

Similar to Beginning Python (20)

PDF
05. haskell streaming io
Sebastian Rettig
 
PPTX
Code Like Pythonista
Chiyoung Song
 
PDF
Multiprocessing with python
Patrick Vergain
 
PDF
CoffeeScript - JavaScript in a simple way
Lim Chanmann
 
PPT
Haskell retrospective
chenge2k
 
PDF
Brogramming - Python, Bash for Data Processing, and Git
Ron Reiter
 
PDF
Go Beyond Higher Order Functions: A Journey into Functional Programming
Lex Sheehan
 
PDF
Real World Haskell: Lecture 1
Bryan O'Sullivan
 
PDF
Introduction to Scala for JCConf Taiwan
Jimin Hsieh
 
PDF
Variables & Expressions
Rich Price
 
PPT
Ruby for Perl Programmers
amiable_indian
 
PPT
ppt30
callroom
 
PPT
ppt21
callroom
 
PPT
name name2 n
callroom
 
PPT
ppt9
callroom
 
PPT
test ppt
callroom
 
PPT
ppt18
callroom
 
PPT
name name2 n2.ppt
callroom
 
PPT
ppt2
callroom
 
05. haskell streaming io
Sebastian Rettig
 
Code Like Pythonista
Chiyoung Song
 
Multiprocessing with python
Patrick Vergain
 
CoffeeScript - JavaScript in a simple way
Lim Chanmann
 
Haskell retrospective
chenge2k
 
Brogramming - Python, Bash for Data Processing, and Git
Ron Reiter
 
Go Beyond Higher Order Functions: A Journey into Functional Programming
Lex Sheehan
 
Real World Haskell: Lecture 1
Bryan O'Sullivan
 
Introduction to Scala for JCConf Taiwan
Jimin Hsieh
 
Variables & Expressions
Rich Price
 
Ruby for Perl Programmers
amiable_indian
 
ppt30
callroom
 
ppt21
callroom
 
name name2 n
callroom
 
ppt9
callroom
 
test ppt
callroom
 
ppt18
callroom
 
name name2 n2.ppt
callroom
 
ppt2
callroom
 
Ad

Recently uploaded (20)

PDF
July Patch Tuesday
Ivanti
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
July Patch Tuesday
Ivanti
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Ad

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 [email protected]