SlideShare utilise les cookies pour améliorer les fonctionnalités et les performances, et également pour vous montrer des publicités pertinentes. Si vous continuez à naviguer sur ce site, vous acceptez l’utilisation de cookies. Consultez nos Conditions d’utilisation et notre Politique de confidentialité.
SlideShare utilise les cookies pour améliorer les fonctionnalités et les performances, et également pour vous montrer des publicités pertinentes. Si vous continuez à naviguer sur ce site, vous acceptez l’utilisation de cookies. Consultez notre Politique de confidentialité et nos Conditions d’utilisation pour en savoir plus.
VI. CLASSES AND OBJECTS
Engr. Ranel O. Padon
PYTHON PROGRAMMING TOPICS
•Introduction to Python Programming
•Controlling the Program Flow
•Program Components: Functions, Classes, Packages, and Modules
•Sequences (List and Tuples), and Dictionaries
•Object-Based Programming: Classes and Objects
•Customizing Classes and Operator Overloading
•Object-Oriented Programming: Inheritance and Polymorphism
•Exception Handling and Assertions
•String Manipulation and Regular Expressions
•File Handling and Processing
•GUI Programming Using Tkinter
• Procedural/Imperative (C, FORTRAN, COBOL)
• Object-Oriented (C++, Java, C#, Objective-C)
Objective-C is used in Apple’s OS X and iOS and for customizing its apps.
• Functional Programming (Lisp)
Lisp is used for customizing AutoCAD
• Logic Programming (Prolog)
• Concurrent (Erlang)
1/6) Emphasis is on doing things (algorithms).
2/6) Large programs are divided into smaller programs
known as functions.
3/6) Most of the functions share global data.
4/6) Data are more open around the system from function
5/6) Functions transform data from one form to another.
6/6) Employs top-down approach in program design.
The data of an object can be accessed only by the functions
associated with that object.
Functions of one object can access the functions of other objects.
1/8) Emphasis is on data rather than procedures or algorithms.
2/8) Programs are divided into what are known as objects.
3/8) Data structures are designed such that they characterize
4/8) Functions that operate on the data are tied together in
the data structure.
5/8) Data is hidden and cannot be accessed by external functions.
6/8) Objects may communicate with each other through functions.
7/8) New data and functions can be easily added whenever necessary.
8/8) Follows bottom-up approach in program design.
Benefits of OOP:
1/8) Through inheritance, we can eliminate redundant code and extend
the use of existing classes which is not possible in procedure-oriented
2/8) We can build programs from the standard working modules that
communicate with one another, rather than having to start writing the
code from scratch which happens procedure-oriented approach.
This leads to saving of development time and higher productivity.
Benefits of OOP:
3/8) The principle of data hiding helps the programmer to build secure
programs that cannot be invaded by code in other parts of the program.
4/8) It is possible to have multiple instances of object to co-exist without
Benefits of OOP:
5/8) It is possible to map objects in the problem domain
to those in the program.
6/8) It is easy to partition the work in a project based on objects .
Benefits of OOP:
7/8) Object oriented systems can be easily upgraded from small
to large systems.
8/8) Software complexity can be easily managed.
OOP ﬁrst appeared in the Simula programming language in the 1960s.
• Simula was invented by Ole-Johan Dahl and Kristen Nygaard,
which influenced C++, Java, and C#
• professors Dahl and Nygaard received two very prestigious prizes:
1.) von Neumann medal
2.) Turing prize (the Nobel prize of computer science)
Class Attributes are used to track the state of all
objects/instances of a given class.
They are also known as Static Variables
There are also Class Behaviors (Static Methods), methods
that involve all objects/instances of a given class). In Java,
Static Methods are used heavily by the Math class so that you
could execute methods without creating an object of the Math
• Objects usually have attributes of basic/primitive data types
(string, integers, boolean, etc)
• Composition: when objects whose attributes
are themselves references to objects of other classes
note the gayagaya() method and the tao1.gayagaya(tao2) statement
Deitel, Deitel, Liperi, and Wiedermann - Python: How to Program (2001).
Disclaimer: Most of the images/information used here have no proper source citation, and I do
not claim ownership of these either. I don’t want to reinvent the wheel, and I just want to reuse
and reintegrate materials that I think are useful or cool, then present them in another light,
form, or perspective. Moreover, the images/information here are mainly used for
illustration/educational purposes only, in the spirit of openness of data, spreading light, and
empowering people with knowledge.