Beginning Python
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Beginning Python

on

  • 5,707 views

 

Statistics

Views

Total Views
5,707
Views on SlideShare
2,561
Embed Views
3,146

Actions

Likes
2
Downloads
40
Comments
0

16 Embeds 3,146

http://agiliq.com 2109
http://uswaretech.com 955
http://www.python.rk.edu.pl 54
http://python.rk.edu.pl 4
http://127.0.0.1 4
http://www.slideshare.net 4
http://translate.googleusercontent.com 3
http://buyitnw.appspot.com 2
http://feeds.feedburner.com 2
http://xss.yandex.net 2
https://agiliq.com 2
https://www.4proxy.de 1
http://dev.agiliq.com 1
http://webcache.googleusercontent.com 1
http://74.125.77.132 1
http://www.agiliq.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Beginning Python Presentation Transcript

  • 1. Shabda Raaj
  • 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