SlideShare a Scribd company logo
ABU ZAHED JONY
“Quotes”

 Perl is worse than Python because people wanted it worse
 - Larry Wall, Creator of Perl
 Python fits your brain
 - Bruce Eckel, Author: Thinking in Java
 Python is an excellent language & makes sensible
  compromises.
 - Peter Norvig. AI

 Life is better without brackets
About Python
 very clear, readable syntax
 portable
 intuitive object orientation
 natural expression of procedural code
 full modularity, supporting hierarchical packages
 very high level dynamic data types
 extensive standard libraries and third party modules for
  virtually every task
 extensions and modules easily written in C, C++ (or Java for
  Jython, or .NET languages for IronPython)
Hello World
print “Hello World”
 Hello World
a=6
print a;

 6


a=‘Hello’
a=a+ 6


 Errors               a=a + str(6)
*.py
Interpreter Output
Interpreter
Strings
a=‘Hello’
a=“Hello”
a=“I Can’t do this”
a=“I ”Love” Python”
a=‘I “Love” Python’
Hello
Hello
I Can’t do this
I “Love” Python
I “Love” Python
a=“Hello”
print a[0]
print len(a)
print a[0:2]
print a[2:]

H
5
He
llo
a=“Hello”


print a[-1]
print a[-2:]

 o
lo
More About str Class
print dir(str)
 ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__',
'__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__',
'__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__',
'__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith',
'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle',
'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust',
'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title',
'translate', 'upper', 'zfill']
Help Class
print help(str.find)
find(...)
   S.find(sub [,start [,end]]) -> int

  Return the lowest index in S where substring sub is found,
  such that sub is contained within s[start,end]. Optional
  arguments start and end are interpreted as in slice notation.

  Return -1 on failure.
Some Basic Syntax(1)




n Odd
n is Odd and greater than 5
n divided by 2 or 5
Some Basic Syntax(1)
               //Array Declaration
               a=[]




2
1
5
Using Range:
2
1
5
True
List(1)
a=[3,1,5]
b=[4,2]
c=a+b
print c
del c[2]
print c
print len(c)
[3,1,5,4,2]
[3,1,4,2]
4
List(2)
(a,b)=([3,1,5],[4,2])
c=a+b
                                       c= sorted(c)
print sorted(c)
print a==b
print sorted(c,reverse=True)
print c
print help(sorted)
[1,2,3,4,5]
False
[5,4,3,2,1]
[3, 1, 5, 4, 2]
Help on built-in function sorted in module __builtin__:
sorted(...)
   sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list
List and Sort
a=['ax','aae','aac']
                       return 1,”Hello World”

def mFun(s):
                       a,b=mFun(“Hi”)
  return s[-1]

print sorted(a,key=mFun)
print sorted(a,key=mFun,reverse=True)
print sorted(a,key=len)
['aac', 'aae', 'ax']
['ax', 'aae', 'aac']
['ax', 'aae', 'aac']
Tuples
a=(1,2,1)
print a[0]
print len(a)
b=[(1,2,3),(1,2,1),(1,4,1)]
print a in b

1
3
True
Tuples and sort
a=[(1,"b"),(2,"a"),(1,"e")]
print a
print sorted(a)
def myTSort(d):
  return d[0]
print sorted(a,key=myTSort)
k=(1,”e”)
print k in a

[(1, 'b'), (2, 'a'), (1, 'e')]
[(1, 'b'), (1, 'e'), (2, 'a')]
[(2, 'a'), (1, 'b'), (1, 'e')]
True
Dictionary


 d={}

 d[‘a’]=‘alpha’
 d[‘o’]=‘omega’
 d[‘g’]=‘gamma’

 print d[‘a’]
  alpha
Dictionary
d={}
(d['a'],d['o'],d['g'])=("alpha","omega","gamma")
print d
print len(d)
{'a': 'alpha', 'g': 'gamma', 'o': 'omega'}
3


Check a value is in dictionary ???

‘a’ in d
Dictionary
d={}
(d['a'],d['o'],d['g'])=("alpha","omega","gamma")
print d[‘a’]
print d[‘x’] //???
print d.get(‘x’) // return None
print d.get(‘a’)

 if(d.get(‘a’)){
      print ‘Yes’
 }
Dictionary
d={}
(d['a'],d['o'],d['g'])=("alpha","omega","gamma")
print d.keys()
print d.values()
print d.items()
['a', 'g', 'o']
['alpha', 'gamma', 'omega']
[('a', 'alpha'), ('g', 'gamma'), ('o', 'omega')]
What needs for sorted dictionary data(key order) ???
All data returns random order

for k in sorted( d.keys() ):
  print d[k]

print sorted(d.keys())
Dictionary
print dir(dict)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__',
'__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__gt__',
'__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__setitem__', '__str__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items',
'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update',
'values']

print help(dict)


print help(dict.items)
File
def readFile(fileName):   // File write
  f=open(fileName,'r')    f=open(fileName,‘w')
                          f.write(data)
  for line in f:
                          f.close()
     print line,
   f.close()

def readFile(fileName):
  f=open(fileName,'r')
  text=f.read()
  print text
  f.close()


 f.seek(5)
Regular expression
import re

match=re.search('od',"God oder")
print match.group()
match=re.search(r'od',"God oder")
print match.group()

od
od
Regular expression
import re

print re.findall(r'ar+','a ar arr')
print re.findall(r'ar*','a ar arr')

['ar', 'arr']
['a', 'ar', 'arr']


+ for 1 or more
* for 0 or more

print dir(re)
Utility: OS
import os
print dir(os)
['F_OK', 'O_APPEND', 'O_BINARY', 'O_CREAT', 'O_EXCL',
'O_NOINHERIT', 'O_RANDOM', 'O_RDONLY', 'O_RDWR',
'O_SEQUENTIAL', 'UserDict', 'W_OK', 'X_OK', '_Environ', '__all__',
'__builtins__', '__doc__', '__file__', '__name__', '_copy_reg',
'_pickle_statvfs_result', 'abort', 'access', 'altsep', 'chdir', 'chmod', 'close',
'curdir', 'defpath', 'isatty', 'linesep', 'listdir', 'lseek', 'lstat', 'makedirs', 'mkdir',
'name', 'open', 'pardir', 'path', 'pathsep', 'pipe', 'popen', 'popen2', 'popen3',
'popen4', 'putenv', 'read', 'remove', 'removedirs', 'rename', 'renames', 'rmdir',
'sep', 'spawnl', 'spawnle', 'spawnv', 'spawnve', 'startfile', 'stat',
'stat_float_times', 'stat_result', 'statvfs_result', 'strerror', 'sys', 'system',
'tempnam', 'times', 'tmpfile', 'tmpnam', 'umask', 'unlink', 'unsetenv',
'urandom', 'utime', 'waitpid', 'walk', 'write']
Utility: OS
import os
print help(os.unlink)
unlink(...)
  unlink(path)
  Remove a file (same as remove(path)).

print help(os.rmdir)


rmdir(...)
  rmdir(path)
  Remove a directory.
Utility: HTTP request, URL




try:
    pass
except:
    pass
finally:
    print “ok”
Some OOP




 class MyClass(AnotherClass):
 import myClass.py
Some OOP (Thread)
Access Shared Resource
Database(Sqlite)
Database(MySql)
Reserved Word
   and           finally      pass
   assert        for          print
   break         from         raise
   class         global       return
   continue      if           try
   def           import       while
   del           in
   elif          is
   else          lambda
   except        not
   exec          or
Code Source


      http://jpython.blogspot.com/
Resource

 http://www.learnpython.org/
 http://learnpythonthehardway.org/book/
 http://code.google.com/edu/languages/google-
 python-class/

 http://love-python.blogspot.com
 http://jpython.blogspot.com
THANK YOU

More Related Content

PDF
Python and sysadmin I
ODP
Programming Under Linux In Python
PDF
Python于Web 2.0网站的应用 - QCon Beijing 2010
KEY
Erlang/OTP for Rubyists
PPT
Profiling and optimization
ZIP
Round PEG, Round Hole - Parsing Functionally
PDF
Fun never stops. introduction to haskell programming language
PPTX
Basics of Python programming (part 2)
Python and sysadmin I
Programming Under Linux In Python
Python于Web 2.0网站的应用 - QCon Beijing 2010
Erlang/OTP for Rubyists
Profiling and optimization
Round PEG, Round Hole - Parsing Functionally
Fun never stops. introduction to haskell programming language
Basics of Python programming (part 2)

What's hot (20)

PDF
Python fundamentals - basic | WeiYuan
PDF
Python Performance 101
PPTX
Introduction to Python and TensorFlow
PPT
Euro python2011 High Performance Python
PPTX
Learn python - for beginners - part-2
PDF
Learn 90% of Python in 90 Minutes
PPTX
Learn python in 20 minutes
PPT
Functional Programming In Java
PDF
Matlab and Python: Basic Operations
PDF
Functional Programming with Groovy
PDF
Advanced Python, Part 2
PDF
Functional programming in java
PPTX
Introduction to the basics of Python programming (part 3)
PDF
Functional Programming & Event Sourcing - a pair made in heaven
KEY
Metaprogramming in Haskell
PDF
Haskell in the Real World
PDF
Hammurabi
PDF
awesome groovy
ODP
An Intro to Python in 30 minutes
PDF
Logic programming a ruby perspective
Python fundamentals - basic | WeiYuan
Python Performance 101
Introduction to Python and TensorFlow
Euro python2011 High Performance Python
Learn python - for beginners - part-2
Learn 90% of Python in 90 Minutes
Learn python in 20 minutes
Functional Programming In Java
Matlab and Python: Basic Operations
Functional Programming with Groovy
Advanced Python, Part 2
Functional programming in java
Introduction to the basics of Python programming (part 3)
Functional Programming & Event Sourcing - a pair made in heaven
Metaprogramming in Haskell
Haskell in the Real World
Hammurabi
awesome groovy
An Intro to Python in 30 minutes
Logic programming a ruby perspective
Ad

Similar to python beginner talk slide (20)

PPTX
Python Workshop - Learn Python the Hard Way
PDF
Introduction to python
PDF
Ejercicios de estilo en la programación
PDF
Is Haskell an acceptable Perl?
PDF
Python utan-stodhjul-motorsag
PPT
Object Orientation vs. Functional Programming in Python
PDF
Music as data
PDF
Python basic
PPTX
GE8151 Problem Solving and Python Programming
PPT
Python classes in mumbai
PDF
Ry pyconjp2015 turtle
PDF
Practical Functional Programming Presentation by Bogdan Hodorog
PDF
A Few of My Favorite (Python) Things
PDF
Python Workshop. LUG Maniapl
PDF
Intro to Python
PPTX
cover every basics of python with this..
PDF
A gentle introduction to functional programming through music and clojure
KEY
Clojure Intro
PDF
Pune Clojure Course Outline
ODP
Introduction to R
Python Workshop - Learn Python the Hard Way
Introduction to python
Ejercicios de estilo en la programación
Is Haskell an acceptable Perl?
Python utan-stodhjul-motorsag
Object Orientation vs. Functional Programming in Python
Music as data
Python basic
GE8151 Problem Solving and Python Programming
Python classes in mumbai
Ry pyconjp2015 turtle
Practical Functional Programming Presentation by Bogdan Hodorog
A Few of My Favorite (Python) Things
Python Workshop. LUG Maniapl
Intro to Python
cover every basics of python with this..
A gentle introduction to functional programming through music and clojure
Clojure Intro
Pune Clojure Course Outline
Introduction to R
Ad

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
sap open course for s4hana steps from ECC to s4
Understanding_Digital_Forensics_Presentation.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectroscopy.pptx food analysis technology
Programs and apps: productivity, graphics, security and other tools
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
MYSQL Presentation for SQL database connectivity
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
20250228 LYD VKU AI Blended-Learning.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

python beginner talk slide

  • 2. “Quotes”  Perl is worse than Python because people wanted it worse - Larry Wall, Creator of Perl  Python fits your brain - Bruce Eckel, Author: Thinking in Java  Python is an excellent language & makes sensible compromises. - Peter Norvig. AI Life is better without brackets
  • 3. About Python  very clear, readable syntax  portable  intuitive object orientation  natural expression of procedural code  full modularity, supporting hierarchical packages  very high level dynamic data types  extensive standard libraries and third party modules for virtually every task  extensions and modules easily written in C, C++ (or Java for Jython, or .NET languages for IronPython)
  • 4. Hello World print “Hello World” Hello World a=6 print a; 6 a=‘Hello’ a=a+ 6 Errors a=a + str(6)
  • 8. Strings a=‘Hello’ a=“Hello” a=“I Can’t do this” a=“I ”Love” Python” a=‘I “Love” Python’ Hello Hello I Can’t do this I “Love” Python I “Love” Python
  • 9. a=“Hello” print a[0] print len(a) print a[0:2] print a[2:] H 5 He llo
  • 11. More About str Class print dir(str) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
  • 12. Help Class print help(str.find) find(...) S.find(sub [,start [,end]]) -> int Return the lowest index in S where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure.
  • 13. Some Basic Syntax(1) n Odd n is Odd and greater than 5 n divided by 2 or 5
  • 14. Some Basic Syntax(1) //Array Declaration a=[] 2 1 5 Using Range: 2 1 5 True
  • 15. List(1) a=[3,1,5] b=[4,2] c=a+b print c del c[2] print c print len(c) [3,1,5,4,2] [3,1,4,2] 4
  • 16. List(2) (a,b)=([3,1,5],[4,2]) c=a+b c= sorted(c) print sorted(c) print a==b print sorted(c,reverse=True) print c print help(sorted) [1,2,3,4,5] False [5,4,3,2,1] [3, 1, 5, 4, 2] Help on built-in function sorted in module __builtin__: sorted(...) sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list
  • 17. List and Sort a=['ax','aae','aac'] return 1,”Hello World” def mFun(s): a,b=mFun(“Hi”) return s[-1] print sorted(a,key=mFun) print sorted(a,key=mFun,reverse=True) print sorted(a,key=len) ['aac', 'aae', 'ax'] ['ax', 'aae', 'aac'] ['ax', 'aae', 'aac']
  • 19. Tuples and sort a=[(1,"b"),(2,"a"),(1,"e")] print a print sorted(a) def myTSort(d): return d[0] print sorted(a,key=myTSort) k=(1,”e”) print k in a [(1, 'b'), (2, 'a'), (1, 'e')] [(1, 'b'), (1, 'e'), (2, 'a')] [(2, 'a'), (1, 'b'), (1, 'e')] True
  • 20. Dictionary d={} d[‘a’]=‘alpha’ d[‘o’]=‘omega’ d[‘g’]=‘gamma’ print d[‘a’] alpha
  • 21. Dictionary d={} (d['a'],d['o'],d['g'])=("alpha","omega","gamma") print d print len(d) {'a': 'alpha', 'g': 'gamma', 'o': 'omega'} 3 Check a value is in dictionary ??? ‘a’ in d
  • 22. Dictionary d={} (d['a'],d['o'],d['g'])=("alpha","omega","gamma") print d[‘a’] print d[‘x’] //??? print d.get(‘x’) // return None print d.get(‘a’) if(d.get(‘a’)){ print ‘Yes’ }
  • 23. Dictionary d={} (d['a'],d['o'],d['g'])=("alpha","omega","gamma") print d.keys() print d.values() print d.items() ['a', 'g', 'o'] ['alpha', 'gamma', 'omega'] [('a', 'alpha'), ('g', 'gamma'), ('o', 'omega')] What needs for sorted dictionary data(key order) ??? All data returns random order for k in sorted( d.keys() ): print d[k] print sorted(d.keys())
  • 24. Dictionary print dir(dict) ['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values'] print help(dict) print help(dict.items)
  • 25. File def readFile(fileName): // File write f=open(fileName,'r') f=open(fileName,‘w') f.write(data) for line in f: f.close() print line, f.close() def readFile(fileName): f=open(fileName,'r') text=f.read() print text f.close() f.seek(5)
  • 26. Regular expression import re match=re.search('od',"God oder") print match.group() match=re.search(r'od',"God oder") print match.group() od od
  • 27. Regular expression import re print re.findall(r'ar+','a ar arr') print re.findall(r'ar*','a ar arr') ['ar', 'arr'] ['a', 'ar', 'arr'] + for 1 or more * for 0 or more print dir(re)
  • 28. Utility: OS import os print dir(os) ['F_OK', 'O_APPEND', 'O_BINARY', 'O_CREAT', 'O_EXCL', 'O_NOINHERIT', 'O_RANDOM', 'O_RDONLY', 'O_RDWR', 'O_SEQUENTIAL', 'UserDict', 'W_OK', 'X_OK', '_Environ', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '_copy_reg', '_pickle_statvfs_result', 'abort', 'access', 'altsep', 'chdir', 'chmod', 'close', 'curdir', 'defpath', 'isatty', 'linesep', 'listdir', 'lseek', 'lstat', 'makedirs', 'mkdir', 'name', 'open', 'pardir', 'path', 'pathsep', 'pipe', 'popen', 'popen2', 'popen3', 'popen4', 'putenv', 'read', 'remove', 'removedirs', 'rename', 'renames', 'rmdir', 'sep', 'spawnl', 'spawnle', 'spawnv', 'spawnve', 'startfile', 'stat', 'stat_float_times', 'stat_result', 'statvfs_result', 'strerror', 'sys', 'system', 'tempnam', 'times', 'tmpfile', 'tmpnam', 'umask', 'unlink', 'unsetenv', 'urandom', 'utime', 'waitpid', 'walk', 'write']
  • 29. Utility: OS import os print help(os.unlink) unlink(...) unlink(path) Remove a file (same as remove(path)). print help(os.rmdir) rmdir(...) rmdir(path) Remove a directory.
  • 30. Utility: HTTP request, URL try: pass except: pass finally: print “ok”
  • 31. Some OOP class MyClass(AnotherClass): import myClass.py
  • 36. Reserved Word  and  finally  pass  assert  for  print  break  from  raise  class  global  return  continue  if  try  def  import  while  del  in  elif  is  else  lambda  except  not  exec  or
  • 37. Code Source http://jpython.blogspot.com/
  • 38. Resource  http://www.learnpython.org/  http://learnpythonthehardway.org/book/  http://code.google.com/edu/languages/google- python-class/  http://love-python.blogspot.com  http://jpython.blogspot.com