intro to python

19

Click here to load reader

Upload: petrov

Post on 17-May-2015

2.405 views

Category:

Business


2 download

DESCRIPTION

Presentation about introductory Python delivered in front of CSSU.

TRANSCRIPT

Page 1: Intro to Python

Intro to Python

CSSU Nov/28/2007

By Georgi Petrov & Atanas Dyulgerov

Page 2: Intro to Python

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

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

Python Advantages Elegant syntax Safe Object-oriented Powerful Portable Free

Page 5: Intro to Python

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

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

Who uses Python Google NASA Rackspace Industrial Light & Magic

Page 8: Intro to Python

Syntax - Indentation

Page 9: Intro to Python

Syntax - Operators Comparison Operators

==, <, >, <=, >= Logical Operators

Zero values are treated as “”, 0, None, 0.0, [] and {}

Page 10: Intro to Python

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

Python Standard Library The greatest strengths of Python Hundreds of modules Examples

Syntax: import email

email, math, calendar, HTMLParser

Page 12: Intro to Python

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

Demo 1 Adjusting Apache to read Python Sample “Hello World” script

Page 14: Intro to Python

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

Object Orientation

Self

Instantiating myObject = myClass()

Calling and addressing myObject.someFunction()

Deletion del myObject.someNumber

Page 16: Intro to Python

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

Demo 2 Brief networking info Sockets SocketServer Framework Ports and Addresses Demo

Page 18: Intro to Python

References http://wiki.python.org http://www.python.org/ http://en.wikipedia.org/wiki/

Python_(programming_language)

Page 19: Intro to Python

Thank You

Q & A