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
6. “Remarkable power with very clear syntax” Python is an Interpreted, Object Oriented Programming language. …it’s named after a television series Monty Python’s Flying Circus It was created by Guido Van Rossum in the year 1990… What is Python ??
7. 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 …“Life's better without braces(Bruce Eckel)” Extremely Portable (Windows,Linux,Unix,Mac… etc) Powerful Standard libraries
13. None Numbers and Floats Complex Numbers …. (i + j) Floating point Boolean…. True or False “Strings” u“Unicode” Tuples () Lists [] Dictonaries {} Built-in Function “type()” Data Types and Containers
14. If, else, elif…. Try and except While Loop For Loop Conditions and Loops
15. List Comprehension Functions Doc Strings … Smart way of Documenting modules File Handling …… read , write , append to file Session 2
16. Single [ <item operation> for item in sequence <if condition>] Nested Special care has to be taken for the nested list comprehension: ….when nesting list comprehensions, read from right to left. List Comprehension
17. Function Definition :- def name (arg1, arg2…. , argn) “““ Documentation ””” #optional statements . . . return expression name(arg1,arg2) # Call to <name> Functions
18. 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 File Handling
19. f = open(filename, [mode]) read(), readline(), readlines() write(), writelines() seek(pos), tell() close() File Objects and Methods
20. Session 3 Classes Class Definition Class Objects Class Data members Class Methods Class Inheritance
21. Class Definition class Stack: "A well-known data structure…" def __init__(self): # constructor self.items = [] def push(self, x): self.items.append(x) #. Push into the Stack…the sky is the limit def pop(self): x = self.items[-1] # Pop from the stack del self.items[-1] return x def empty(self): return len(self.items) == 0 # Boolean result
22. Class Objects , Methods and Data Members object = Stack() #--- Object of the Class “Stack” ….. Constructor invoked during Object instantiation object.push(arg1) #---- Call to Class Method “push” print object.items #---- Access the Class Data Member
23. Inheritance class BaseClass: baseDataVar = 10 def baseMethods(self) statements class DerivedClass(BaseClass): def Method() print self.baseDataVar self.baseMethods() #-- Call to base class method