SlideShare a Scribd company logo
PYTHON Volkan Tüfekçi – Gülcan Aydın 26.12.2007
History Philosphy Usage Guido  van Rossum  1989 Hobby Language ABC – Modula 3 – Unix/C – Common Lisp - Haskell Dislikes: D ifficulty of adding new "primitive" operations M onolithic, "closed system“ , basic I/O operations I deosyncratic syntax (all uppercase keywords!) Aims: Readability Rely on the  Unix infrastructure and conventions, without being Unix-bound I mportance of programmer effort over computer effort 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
History Philosphy Usage(cont.) 1991 S yntax and semantics are  minimalist , while the  standard library  is large and comprehensive multi-paradigm programming language :  object orientation  and  structured programming   -> fully functional programming  and  aspect-oriented programming  -> by language features pyDBC  and  Contracts for Python  which allow  Design by Contract dynamic  name resolution  (late binding) New built-in modules are easily written in  C  or  C++ Python philosophy rejects exuberant syntax, such as in  Perl PyQt, PyGTK, PyCon, PyPy 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
History Philosphy Usage(cont.) Nasa, Google, YouTube, BitTorrent, Air Canada’s Reservation Management TurboGears, Django(NewYork Times’ web site) Maya, Blender Fedora, Gentoo, Pardus Jython, IronPython 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Introduction to O-O Python Python is an object-oriented programming language.   Supports procedural programming with modules and functions.   Generally, the O-O paradigm is suitable when you want to group state (data) and behavior (code) together in handy packets of functionality.   The procedural paradigm, based on modules and functions, tends to be simpler and is more suitable when you don't need any of the benefits of object-oriented programming. 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Syntax All values in Python can be used as logic values. Some of the more “empty” ones, like [], 0, “” and None represent logical falsity, while most other values (like [0], 1 or “Hello, world”) represent logical truth. if  0 < month <= 12: doSomething() 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Dictionaries  1 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN A dictionary in Python is like an instance of the Hashtable class in Java No duplicate member No order Mutable
Dictionaries  2 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
List s  1 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
List s  2 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
List s  3 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
List & Dictionary Examples L=[1,2,3,4,5] IMPORTANT : The value will be stored into a range of memory blocks, and what if we do this?  L2=L  It make L2 refers to the same memory blocks where L points to. Example;  29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
List C omprehension s 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Tuples 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN A tuple is an immutable list. A tuple can not be changed in any way once it is created Tuples are faster than lists It makes your code safer if you “write-protect” data Tuples can be converted into lists, and vice-versa.
Assigning Variables 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
String Formatting & Concatenating 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN # 1 membered Tuple!!! # Strong typed
Importing Modules & Getting Help 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
String Operation Examples 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Modules from UserDict import UserDict
Constructor A constructor is a method that initializes a newly created object. The overridden derived-class constructor usually calls the base-class constructor, to initialize base-class attributes before initializing derived-class attributes.   If a derived class does not define a constructor, the class’s base-class constructor executes when the client creates a new object of the class.   29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Destructor & Static Variable 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN D oes not actually destroy the object # Static variable # 0 # 2 # 0
Static Methods 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Property Descriptor 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Slots Attribute 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN >>>8
Inheritance Inheritance is a form of software reusability in which new classes are created from existing classes by absorbing their attributes and behaviors. The new class is referred to as a  derived class,  inherit from the class referred to as  base class. With  single inheritance, a class is derived from one base class. With  multiple inheritance,  a derived class inherits from several base classes. 29/05/09 CSE 494  Volkan TÜFEKÇİ -  Gülcan  AYDIN
(cont.) We distinguish between  “is-a” relationships  and  “has-a” relationships: “ Is a” is inheritance. In an “is a” relationship, an object of a derived-class type may also be treated as an object of the base-class type. “ Has a” is composition. In a “has a” relationship, an object  has  references to one or more objects of other classes as members. 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
“ is a” Inheritance hierarchy for university community members : 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Multiple Inheritance and Name Clash Problem   class Base1:  def amethod(self):   print &quot;Base1“ class Base2(Base1): pass    # pass!!! class Base3:  def amethod(self):  print &quot;Base3&quot;  class Derived(Base2, Base3): pass  aninstance = Derived( )  aninstance.amethod( )  # prints: &quot;Base1&quot;   29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Data Abstraction One of the fundamental principles of good software engineering is that a client should not need to know how a class is implemented to use that class.  Python’s use of modules facilitates this data abstraction—a program can import a class definition and use the class without knowing how the class is implemented.   29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Encapsulation No methods or member variables are protected (or private or the like) in Python.   Encapsulation is pretty much a matter of programming style.  If you really need it, there are naming-conventions that will allow some privacy. such as;  _ _ident   Python compiler implicitly changes the identifier into  _classname_ _ident , where  classname  is the name of the class.   29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Example of Private Data Access 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Abstract Classes 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN Traceback (most recent call last): b.earnings() raise NotImplementedError, &quot;Cannot call abstract method&quot; NotImplementedError: Cannot call abstract method
Polymorphism 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Polymorphism 2 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Polymorphism 3 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Polymorphism 4 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Polymorphism 5 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
Composition vs. Inheritance composition of existing classes Employee  is a BirthDate or that an Employee is a TelephoneNumber Employee  has a BirthDate and that an Employee has a  TelephoneNumber. 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN
“ Uses A” and “Knows A” Relationships a person object is not a car and a person object does not contain a car, a   person object certainly  uses a car A program uses an object simply by calling a method of   that object through a reference. one object is said to have a  knows a relationship with the other object;   this is sometimes called an  association. 29/05/09 CSE 494  Volkan TÜFEKÇİ - Gülcan AYDIN

More Related Content

PPTX
Adana
PPTX
Symbian os
PPTX
Image Processing by AIA
PPT
Hatay cuisine2
PPT
My town adana
PPS
Moskova
PPT
PPT
Marketing of CSE Department
Adana
Symbian os
Image Processing by AIA
Hatay cuisine2
My town adana
Moskova
Marketing of CSE Department

Viewers also liked (17)

PPTX
Kenba Travels resa "Antalya Riviera"
PPTX
Adana slide
PPTX
PPTX
Aydın şehir tanıtım sunusu Aydın introduction
PPTX
MERSİN'İN TANITIMI
PPTX
Voice browser
PPTX
Antalya Turkey
PPT
Types of machine translation
PPTX
Java ring
PPS
KEY
Yii Framework
PPT
Digital signature schemes
PPTX
Search engine
PPTX
Java ring Engg SEMINAR
PDF
8 memory management strategies
PPT
Kahraman Maraş Our City
PPTX
Search Engines Presentation
Kenba Travels resa "Antalya Riviera"
Adana slide
Aydın şehir tanıtım sunusu Aydın introduction
MERSİN'İN TANITIMI
Voice browser
Antalya Turkey
Types of machine translation
Java ring
Yii Framework
Digital signature schemes
Search engine
Java ring Engg SEMINAR
8 memory management strategies
Kahraman Maraş Our City
Search Engines Presentation
Ad

Similar to Python (20)

PPTX
Inheritance
PPTX
Python programming computer science and engineering
PDF
Python Foundation – A programmer's introduction to Python concepts & style
PPT
Python Kick Start
PPTX
Class 27: Pythonic Objects
PDF
Quick python reference
PPT
python within 50 page .ppt
PPTX
PRESENTATION ON PYTHON.pptx
PPT
Python001 training course_mumbai
PPTX
Python Workshop - Learn Python the Hard Way
PPT
Introduction to the intermediate Python - v1.1
PPTX
Python Basic for Data science enthusiast
PPTX
Python PPT by Sushil Sir.pptx
PDF
Introduction to Python
PPT
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
PDF
Let's learn python
PPTX
Object Oriented Programming.pptx
PPT
Pythonintroduction
PDF
Introduction To Programming with Python
PPT
Oops ppt
Inheritance
Python programming computer science and engineering
Python Foundation – A programmer's introduction to Python concepts & style
Python Kick Start
Class 27: Pythonic Objects
Quick python reference
python within 50 page .ppt
PRESENTATION ON PYTHON.pptx
Python001 training course_mumbai
Python Workshop - Learn Python the Hard Way
Introduction to the intermediate Python - v1.1
Python Basic for Data science enthusiast
Python PPT by Sushil Sir.pptx
Introduction to Python
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
Let's learn python
Object Oriented Programming.pptx
Pythonintroduction
Introduction To Programming with Python
Oops ppt
Ad

Recently uploaded (20)

PDF
WRN_Investor_Presentation_August 2025.pdf
PPTX
Business Ethics - An introduction and its overview.pptx
PPTX
AI-assistance in Knowledge Collection and Curation supporting Safe and Sustai...
PPTX
Dragon_Fruit_Cultivation_in Nepal ppt.pptx
PDF
A Brief Introduction About Julia Allison
PDF
20250805_A. Stotz All Weather Strategy - Performance review July 2025.pdf
PPTX
ICG2025_ICG 6th steering committee 30-8-24.pptx
DOCX
Business Management - unit 1 and 2
PDF
Training And Development of Employee .pdf
PPT
Data mining for business intelligence ch04 sharda
PDF
Katrina Stoneking: Shaking Up the Alcohol Beverage Industry
PDF
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
PPT
340036916-American-Literature-Literary-Period-Overview.ppt
PDF
Types of control:Qualitative vs Quantitative
PPTX
New Microsoft PowerPoint Presentation - Copy.pptx
PDF
Power and position in leadershipDOC-20250808-WA0011..pdf
PDF
MSPs in 10 Words - Created by US MSP Network
PDF
Deliverable file - Regulatory guideline analysis.pdf
PPTX
CkgxkgxydkydyldylydlydyldlyddolydyoyyU2.pptx
PDF
Laughter Yoga Basic Learning Workshop Manual
WRN_Investor_Presentation_August 2025.pdf
Business Ethics - An introduction and its overview.pptx
AI-assistance in Knowledge Collection and Curation supporting Safe and Sustai...
Dragon_Fruit_Cultivation_in Nepal ppt.pptx
A Brief Introduction About Julia Allison
20250805_A. Stotz All Weather Strategy - Performance review July 2025.pdf
ICG2025_ICG 6th steering committee 30-8-24.pptx
Business Management - unit 1 and 2
Training And Development of Employee .pdf
Data mining for business intelligence ch04 sharda
Katrina Stoneking: Shaking Up the Alcohol Beverage Industry
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
340036916-American-Literature-Literary-Period-Overview.ppt
Types of control:Qualitative vs Quantitative
New Microsoft PowerPoint Presentation - Copy.pptx
Power and position in leadershipDOC-20250808-WA0011..pdf
MSPs in 10 Words - Created by US MSP Network
Deliverable file - Regulatory guideline analysis.pdf
CkgxkgxydkydyldylydlydyldlyddolydyoyyU2.pptx
Laughter Yoga Basic Learning Workshop Manual

Python

  • 1. PYTHON Volkan Tüfekçi – Gülcan Aydın 26.12.2007
  • 2. History Philosphy Usage Guido van Rossum 1989 Hobby Language ABC – Modula 3 – Unix/C – Common Lisp - Haskell Dislikes: D ifficulty of adding new &quot;primitive&quot; operations M onolithic, &quot;closed system“ , basic I/O operations I deosyncratic syntax (all uppercase keywords!) Aims: Readability Rely on the Unix infrastructure and conventions, without being Unix-bound I mportance of programmer effort over computer effort 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 3. History Philosphy Usage(cont.) 1991 S yntax and semantics are minimalist , while the standard library is large and comprehensive multi-paradigm programming language : object orientation and structured programming -> fully functional programming and aspect-oriented programming -> by language features pyDBC and Contracts for Python which allow Design by Contract dynamic name resolution (late binding) New built-in modules are easily written in C or C++ Python philosophy rejects exuberant syntax, such as in Perl PyQt, PyGTK, PyCon, PyPy 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 4. History Philosphy Usage(cont.) Nasa, Google, YouTube, BitTorrent, Air Canada’s Reservation Management TurboGears, Django(NewYork Times’ web site) Maya, Blender Fedora, Gentoo, Pardus Jython, IronPython 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 5. Introduction to O-O Python Python is an object-oriented programming language. Supports procedural programming with modules and functions. Generally, the O-O paradigm is suitable when you want to group state (data) and behavior (code) together in handy packets of functionality. The procedural paradigm, based on modules and functions, tends to be simpler and is more suitable when you don't need any of the benefits of object-oriented programming. 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 6. Syntax All values in Python can be used as logic values. Some of the more “empty” ones, like [], 0, “” and None represent logical falsity, while most other values (like [0], 1 or “Hello, world”) represent logical truth. if 0 < month <= 12: doSomething() 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 7. Dictionaries 1 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN A dictionary in Python is like an instance of the Hashtable class in Java No duplicate member No order Mutable
  • 8. Dictionaries 2 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 9. List s 1 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 10. List s 2 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 11. List s 3 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 12. List & Dictionary Examples L=[1,2,3,4,5] IMPORTANT : The value will be stored into a range of memory blocks, and what if we do this? L2=L It make L2 refers to the same memory blocks where L points to. Example; 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 13. List C omprehension s 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 14. Tuples 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN A tuple is an immutable list. A tuple can not be changed in any way once it is created Tuples are faster than lists It makes your code safer if you “write-protect” data Tuples can be converted into lists, and vice-versa.
  • 15. Assigning Variables 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 16. String Formatting & Concatenating 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN # 1 membered Tuple!!! # Strong typed
  • 17. Importing Modules & Getting Help 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 18. String Operation Examples 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 19. Modules from UserDict import UserDict
  • 20. Constructor A constructor is a method that initializes a newly created object. The overridden derived-class constructor usually calls the base-class constructor, to initialize base-class attributes before initializing derived-class attributes. If a derived class does not define a constructor, the class’s base-class constructor executes when the client creates a new object of the class. 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 21. Destructor & Static Variable 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN D oes not actually destroy the object # Static variable # 0 # 2 # 0
  • 22. Static Methods 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 23. Property Descriptor 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 24. Slots Attribute 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN >>>8
  • 25. Inheritance Inheritance is a form of software reusability in which new classes are created from existing classes by absorbing their attributes and behaviors. The new class is referred to as a derived class, inherit from the class referred to as base class. With single inheritance, a class is derived from one base class. With multiple inheritance, a derived class inherits from several base classes. 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 26. (cont.) We distinguish between “is-a” relationships and “has-a” relationships: “ Is a” is inheritance. In an “is a” relationship, an object of a derived-class type may also be treated as an object of the base-class type. “ Has a” is composition. In a “has a” relationship, an object has references to one or more objects of other classes as members. 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 27. “ is a” Inheritance hierarchy for university community members : 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 28. Multiple Inheritance and Name Clash Problem class Base1: def amethod(self): print &quot;Base1“ class Base2(Base1): pass # pass!!! class Base3: def amethod(self): print &quot;Base3&quot; class Derived(Base2, Base3): pass aninstance = Derived( ) aninstance.amethod( ) # prints: &quot;Base1&quot; 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 29. Data Abstraction One of the fundamental principles of good software engineering is that a client should not need to know how a class is implemented to use that class. Python’s use of modules facilitates this data abstraction—a program can import a class definition and use the class without knowing how the class is implemented. 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 30. Encapsulation No methods or member variables are protected (or private or the like) in Python. Encapsulation is pretty much a matter of programming style. If you really need it, there are naming-conventions that will allow some privacy. such as; _ _ident Python compiler implicitly changes the identifier into _classname_ _ident , where classname is the name of the class. 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 31. Example of Private Data Access 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 32. Abstract Classes 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN Traceback (most recent call last): b.earnings() raise NotImplementedError, &quot;Cannot call abstract method&quot; NotImplementedError: Cannot call abstract method
  • 33. Polymorphism 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 34. Polymorphism 2 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 35. Polymorphism 3 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 36. Polymorphism 4 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 37. Polymorphism 5 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 38. Composition vs. Inheritance composition of existing classes Employee is a BirthDate or that an Employee is a TelephoneNumber Employee has a BirthDate and that an Employee has a TelephoneNumber. 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN
  • 39. “ Uses A” and “Knows A” Relationships a person object is not a car and a person object does not contain a car, a person object certainly uses a car A program uses an object simply by calling a method of that object through a reference. one object is said to have a knows a relationship with the other object; this is sometimes called an association. 29/05/09 CSE 494 Volkan TÜFEKÇİ - Gülcan AYDIN