Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Python and You<br />By<br />Karthik Prakash<br />
<ul><li> Introduction to Python
 Interactive “Shell”
 Basic Types and Containers
 Control Structures</li></ul>Session 1<br />
“Remarkable power with very clear syntax”<br />Python is an Interpreted, Object Oriented Programming language.<br />…it’s ...
Features :-<br />Free and Open Source… Maintained by the PSF (Python Software Foundation)<br />Rapid Prototyping<br />Comp...
Two variations:  IDLE (GUI)  and PYTHON (command line)<br />Most Python implementations work on CLI (Command Line Interfac...
Interactive Command Shell
Syntax Highlighting
Auto-Indentation
Auto Completion extended to Intellisence</li></ul>Interactive Shell<br />
None<br />Numbers and Floats<br />Complex Numbers …. (i + j)<br />Floating point<br />Boolean…. True or False<br />“String...
If, else, elif….<br />Try and except<br />While Loop<br />For Loop<br />Conditions and Loops<br />
List Comprehension<br />Functions<br />Doc Strings<br />… Smart way of Documenting modules<br />File Handling<br />…… read...
Single<br />[ <item operation> for item in sequence <if condition>]<br />Nested<br />Special care has to be taken for the ...
Upcoming SlideShare
Loading in …5
×

A Head Start on Python Language

745 views

Published on

This presentation is intended to give the readers a quick and basic overview of the language. Rest will come as you code.

Dive into the Python as its an Ocean

Published in: Technology
  • Be the first to comment

  • Be the first to like this

A Head Start on Python Language

  1. 1. Python and You<br />By<br />Karthik Prakash<br />
  2. 2. <ul><li> Introduction to Python
  3. 3. Interactive “Shell”
  4. 4. Basic Types and Containers
  5. 5. Control Structures</li></ul>Session 1<br />
  6. 6. “Remarkable power with very clear syntax”<br />Python is an Interpreted, Object Oriented Programming language.<br />…it’s named after a television series Monty Python’s Flying Circus<br />It was created by Guido Van Rossum in the year 1990…<br />What is Python ??<br />
  7. 7. Features :-<br />Free and Open Source… Maintained by the PSF (Python Software Foundation)<br />Rapid Prototyping<br />Compiled to interpreted byte code .. sometimes called as Scripting language<br />….i.e Compilation is implicit<br />Indentation for block structure<br /> …“Life's better without braces(Bruce Eckel)”<br />Extremely Portable (Windows,Linux,Unix,Mac… etc)<br />Powerful Standard libraries<br />
  8. 8. Two variations: IDLE (GUI) and PYTHON (command line)<br />Most Python implementations work on CLI (Command Line Interface)<br />Great for learning the language by experimenting with the library<br />Great for testing your own modules <br />Benefits of IDLE<br /><ul><li>Multi Windows Text Editor
  9. 9. Interactive Command Shell
  10. 10. Syntax Highlighting
  11. 11. Auto-Indentation
  12. 12. Auto Completion extended to Intellisence</li></ul>Interactive Shell<br />
  13. 13. None<br />Numbers and Floats<br />Complex Numbers …. (i + j)<br />Floating point<br />Boolean…. True or False<br />“Strings”<br />u“Unicode”<br />Tuples ()<br />Lists []<br />Dictonaries {}<br />Built-in Function “type()”<br />Data Types and Containers<br />
  14. 14. If, else, elif….<br />Try and except<br />While Loop<br />For Loop<br />Conditions and Loops<br />
  15. 15. List Comprehension<br />Functions<br />Doc Strings<br />… Smart way of Documenting modules<br />File Handling<br />…… read , write , append to file<br />Session 2<br />
  16. 16. Single<br />[ <item operation> for item in sequence <if condition>]<br />Nested<br />Special care has to be taken for the nested list comprehension:<br />….when nesting list comprehensions, read from right to left.<br />List Comprehension<br />
  17. 17. Function Definition :-<br />def name (arg1, arg2…. , argn)<br />“““ Documentation ””” #optional <br /> statements<br />.<br />.<br />.<br /> return expression<br />name(arg1,arg2) # Call to <name> <br />Functions<br />
  18. 18. File Modes<br />Mode Meaning <br />'r' open for reading (default) <br />'w' open for writing, truncating the file first <br />'a' open for writing, appending to the end of the file if it exists <br />'b' binary mode<br />File Handling<br />
  19. 19. f = open(filename, [mode])<br />read(), readline(), readlines()<br />write(), writelines()<br />seek(pos), tell()<br />close()<br />File Objects and Methods<br />
  20. 20. Session 3<br />Classes<br />Class Definition<br />Class Objects<br />Class Data members<br />Class Methods<br />Class Inheritance<br />
  21. 21. Class Definition<br />class Stack:<br /> "A well-known data structure…"<br /> def __init__(self): # constructor<br /> self.items = []<br /> def push(self, x):<br /> self.items.append(x) #. Push into the Stack…the sky is the limit<br /> def pop(self):<br /> x = self.items[-1] # Pop from the stack<br /> del self.items[-1]<br /> return x<br /> def empty(self):<br /> return len(self.items) == 0 # Boolean result<br />
  22. 22. Class Objects , Methods and Data Members<br />object = Stack() #--- Object of the Class “Stack”<br /> ….. Constructor invoked during Object instantiation<br />object.push(arg1) #---- Call to Class Method “push”<br />print object.items #---- Access the Class Data Member<br />
  23. 23. Inheritance<br />class BaseClass:<br />baseDataVar = 10<br />def baseMethods(self)<br /> statements<br />class DerivedClass(BaseClass):<br />def Method()<br /> print self.baseDataVar <br />self.baseMethods() #-- Call to base class method<br />

×