intro to python
DESCRIPTION
Presentation about introductory Python delivered in front of CSSU.TRANSCRIPT
![Page 1: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/1.jpg)
Intro to Python
CSSU Nov/28/2007
By Georgi Petrov & Atanas Dyulgerov
![Page 2: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/2.jpg)
Outline What is Python Python Advantages Who uses Python Syntax & Semantics Data Structures Python Standard Library Demo 1 Object Orientation Demo 2
![Page 3: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/3.jpg)
What is Python? interpreted, interactive, object-oriented
programming language Widely used in the industry Cousin of Tcl, Perl and VB Used in web programming and in
standalone applications
![Page 4: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/4.jpg)
Python Advantages Elegant syntax Safe Object-oriented Powerful Portable Free
![Page 5: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/5.jpg)
Python is simple
print "Hello World!"
#include <iostream.h> int main() { cout << "Hello World!"; }
public class helloWorld {
public static void main(String [] args) { System.out.println("Hello World!"); }
}
Python
C++
Java
![Page 6: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/6.jpg)
Python is fun & practical Lack of type declaration Huge library of modules Widespread use in industry Available for all the major platforms
(Windows, MacOS, Linux, Unix, BeOS, Java)
![Page 7: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/7.jpg)
Who uses Python Google NASA Rackspace Industrial Light & Magic
![Page 8: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/8.jpg)
Syntax - Indentation
![Page 9: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/9.jpg)
Syntax - Operators Comparison Operators
==, <, >, <=, >= Logical Operators
Zero values are treated as “”, 0, None, 0.0, [] and {}
![Page 10: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/10.jpg)
Data Structures Base Types
integer, float, long integer, octal integer, hexadecimal integer, complex, character string, list, dictionary, tuples, file
Collection typessequences & mappings
Object system
![Page 11: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/11.jpg)
Python Standard Library The greatest strengths of Python Hundreds of modules Examples
Syntax: import email
email, math, calendar, HTMLParser
![Page 12: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/12.jpg)
Object Oriented Mechanism Similar to C++
and Java Supports multiple
inheritance Polymorphism No private class
members
class Stack: def __init__(self,size): self.data = [None]*size self.size = 0 def push(self,item): self.data[self.size] = item self.size = self.size + 1 def pop(self): self.size = self.size - 1 return self.data[self.size] def is_empty(self): return self.size == 0 def is_full(self): return self.size == len(self.data)
![Page 13: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/13.jpg)
Demo 1 Adjusting Apache to read Python Sample “Hello World” script
![Page 14: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/14.jpg)
Object Orientation Defining classes
class SomeClass: "Just some class...that's all."
Adding data members and methods class SomeClass
"Just some class...that's all."
someNumber = 2131
def someFunction ( self ):
return someNumber
![Page 15: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/15.jpg)
Object Orientation
Self
Instantiating myObject = myClass()
Calling and addressing myObject.someFunction()
Deletion del myObject.someNumber
![Page 16: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/16.jpg)
Object Orientation Constructors
class AnotherClass: def __init__ ( self, anotherArgument ): self.anotherArgument = anotherArgument
Single/Multiple Inheritance and Overriding class ParentClass: def print( self ): print “parent” class ChildClass ( ParentClass ): def print( self ): print “child”
![Page 17: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/17.jpg)
Demo 2 Brief networking info Sockets SocketServer Framework Ports and Addresses Demo
![Page 18: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/18.jpg)
References http://wiki.python.org http://www.python.org/ http://en.wikipedia.org/wiki/
Python_(programming_language)
![Page 19: Intro to Python](https://reader038.vdocuments.net/reader038/viewer/2022100517/55582256d8b42a5e468b505e/html5/thumbnails/19.jpg)
Thank You
Q & A