ByKarthik Prakash
• Introduction to Python• Interactive “Shell”• Basic Types and Containers• Control Structures
“Remarkable power with very clear syntax”Python is an Interpreted, Object OrientedProgramming language.…it’s named after a...
Features :-• Free and Open Source… Maintained by the PSF (Python Software  Foundation)• Rapid Prototyping• Compiled to int...
Two variations: IDLE (GUI) and PYTHON (command line)• Most Python implementations work on CLI (Command Line Interface)• Gr...
•   None•   Numbers and Floats•   Complex Numbers …. (i + j)•   Floating point•   Boolean…. True or False•   “Strings”•   ...
• If, else, elif….• Try and except• While Loop• For Loop
• List Comprehension• Functions• Doc Strings    … Smart way of Documenting modules• File Handling    …… read , write , app...
Single [ <item operation> for item in sequence <if condition>]NestedSpecial care has to be taken for the nested listcompre...
Function Definition :-def name (arg1, arg2…. , argn)  “““ Documentation ””” #optional  statements        .        .       ...
File Modes• Mode Meaning• r open for reading (default)• w open for writing, truncating the file first• a open for writing,...
f = open(filename, [mode])• read(), readline(), readlines()• write(), writelines()• seek(pos), tell()• close()
• Classes  o   Class Definition  o   Class Objects  o   Class Data members  o   Class Methods  o   Class Inheritance
class Stack:"A well-known data structure…"def __init__(self): # constructorself.items = []def push(self, x):self.items.app...
object = Stack() #--- Object of the Class “Stack”….. Constructor invoked during Object instantiationobject.push(arg1) #---...
• class BaseClass:    baseDataVar = 10    def baseMethods(self)    statements    class DerivedClass(BaseClass):    def Met...
Upcoming SlideShare
Loading in …5
×

Python Kick Start

691 views
557 views

Published on

Kick start to the world of Python

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
691
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Python Kick Start

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

×