Movatterモバイル変換


[0]ホーム

URL:


Ranel Padon, profile picture
Uploaded byRanel Padon
PDF, PPTX5,560 views

Python Programming - VI. Classes and Objects

This document discusses classes and objects in Python programming. It covers key concepts like class attributes, instantiating classes to create objects, using constructors and destructors, composition where objects have other objects as attributes, and referencing objects. The document uses examples like a Time class to demonstrate class syntax and how to define attributes and behaviors for classes.

Embed presentation

Download as PDF, PPTX
PYTHON PROGRAMMINGVI. CLASSES AND OBJECTSEngr. Ranel O. Padon
PYTHON PROGRAMMING TOPICSI•Introduction to Python ProgrammingII•Python BasicsIII•Controlling the Program FlowIV•Program Components: Functions, Classes, Packages, and ModulesV•Sequences (List and Tuples), and DictionariesVI•Object-Based Programming: Classes and ObjectsVII•Customizing Classes and Operator OverloadingVIII•Object-Oriented Programming: Inheritance and PolymorphismIX•Randomization AlgorithmsX•Exception Handling and AssertionsXI•String Manipulation and Regular ExpressionsXII•File Handling and ProcessingXIII•GUI Programming Using Tkinter
PROGRAMMING PARADIGMS
PROGRAMMING PARADIGMS• 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)• Multi-Paradigm (Python, Scala, PHP, JavaScript)•…
PROGRAMMING PARADIGMShttp://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
PROGRAMMING PARADIGMShttp://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
PROGRAMMING PARADIGMShttp://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
PROCEDURE-ORIENTED PROGRAMMING
PROCEDURE-ORIENTED PROGRAMMING
PROCEDURE-ORIENTED PROGRAMMING1/6) Emphasis is on doing things (algorithms).2/6) Large programs are divided into smaller programsknown as functions.3/6) Most of the functions share global data.
PROCEDURE-ORIENTED PROGRAMMING4/6) Data are more open around the system from functionto function.5/6) Functions transform data from one form to another.6/6) Employs top-down approach in program design.
OBJECT-ORIENTED PROGRAMMING
OBJECT-ORIENTED PROGRAMMINGThe data of an object can be accessed only by the functionsassociated with that object.Functions of one object can access the functions of other objects.
OBJECT-ORIENTED PROGRAMMING1/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 characterizethe objects.4/8) Functions that operate on the data are tied together inthe data structure.
OBJECT-ORIENTED PROGRAMMING5/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.
OBJECT-ORIENTED PROGRAMMINGBenefits of OOP:1/8) Through inheritance, we can eliminate redundant code and extendthe use of existing classes which is not possible in procedure-orientedapproach.2/8) We can build programs from the standard working modules thatcommunicate with one another, rather than having to start writing thecode from scratch which happens procedure-oriented approach.This leads to saving of development time and higher productivity.
OBJECT-ORIENTED PROGRAMMINGBenefits of OOP:3/8) The principle of data hiding helps the programmer to build secureprograms 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 withoutany interference.
OBJECT-ORIENTED PROGRAMMINGBenefits of OOP:5/8) It is possible to map objects in the problem domainto those in the program.6/8) It is easy to partition the work in a project based on objects .
OBJECT-ORIENTED PROGRAMMINGBenefits of OOP:7/8) Object oriented systems can be easily upgraded from smallto large systems.8/8) Software complexity can be easily managed.
OBJECT-ORIENTED PROGRAMMINGOOP first appeared in the Simula programming language in the 1960s.
OBJECT-ORIENTED PROGRAMMING• 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 medal2.) Turing prize (the Nobel prize of computer science)
OBJECT-ORIENTED PROGRAMMINGAspects of OOP
CLASSES• A class is just like a blueprint of a house.• An object is the actual house built from that blueprint.• You could then create numerous houses/objects from a single blueprint.
CLASSESTwo main components of an Object/Class(these terms are synonymous/equivalent):• Attributes & Behaviors• Variables & Functions• Fields & Methods• Data Members & Member Functions
CLASSES INSTANTIATION
CLASSES
THE TIME CLASS | Time1.py
THE TIME CLASS | Time1.py
THE TIME CLASS | Time1.py
THE TIME CLASS
THE TIME CLASS
THE TIME CLASS
THE TIME CLASS
THE TIME CLASS
SPECIAL ATTRIBUTES Classes
SPECIAL ATTRIBUTES Classes
SPECIAL ATTRIBUTES Objects
SPECIAL ATTRIBUTES Objects
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Protected Var
OBJECT ATTRIBUTES | Protected Var
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | ChainingChaining Comparisons in Other LanguagesConcise Equivalent in Python
OBJECT ATTRIBUTES | ChainingChaining Comparisons
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and GetRaising Exceptions
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Set and Get
OBJECT ATTRIBUTES | Private Var
OBJECT ATTRIBUTES | Private Var
OBJECT ATTRIBUTES | Private Var
CONSTRUCTORS | Default Args
CONSTRUCTORS | Default Args
CONSTRUCTORS | Default Args
CONSTRUCTORS | Default Args
CONSTRUCTORS | Default Args
CONSTRUCTORS | Default Args
CONSTRUCTORS | Default Args
CONSTRUCTORS | Default Args
CONSTRUCTORS | Default Args
DESTRUCTORS• method called __del__• executes when the last reference toan object is deleted or goes out of scope.• specifies no parameters other than self• returns None.
DESTRUCTORS
CLASS ATTRIBUTESClass Attributes are used to track the state of allobjects/instances of a given class.They are also known as Static VariablesThere are also Class Behaviors (Static Methods), methodsthat involve all objects/instances of a given class). In Java,Static Methods are used heavily by the Math class so that youcould execute methods without creating an object of the Mathclass
CLASS ATTRIBUTES
CLASS ATTRIBUTESLists are not restricted to homogeneous data types.Python programmers typically use liststo store sequences of homogeneous values(values of the same data type)
CLASS ATTRIBUTESLists are not restricted to homogeneous data types.Python programmers typically use liststo store sequences of homogeneous values(values of the same data type)
CLASS ATTRIBUTES
COMPOSITION• Objects usually have attributes of basic/primitive data types(string, integers, boolean, etc)• Composition: when objects whose attributesare themselves references to objects of other classes
COMPOSITIONnote the gayagaya() method and the tao1.gayagaya(tao2) statement
COMPOSITION
COMPOSITION
COMPOSITION
COMPOSITION
COMPOSITION
REFERENCES 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 donot claim ownership of these either. I don’t want to reinvent the wheel, and I just want to reuseand 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 forillustration/educational purposes only, in the spirit of openness of data, spreading light, andempowering people with knowledge. 

Recommended

PDF
Python libraries
PPTX
Chapter 05 classes and objects
PPTX
Python OOPs
PPTX
Class, object and inheritance in python
PPTX
Object oriented programming in python
PPTX
Chapter 07 inheritance
PPTX
Object Oriented Programming in Python
PPTX
Python – Object Oriented Programming
PPTX
Python-Classes.pptx
PPT
Oops ppt
PPTX
Introduction to python
PDF
Zero to Hero - Introduction to Python3
PPTX
OOP concepts -in-Python programming language
PPTX
Python Libraries and Modules
PPTX
6-Python-Recursion PPT.pptx
PPTX
Applications of Machine Learning
PPTX
Python-Inheritance.pptx
PDF
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
PPTX
CLASS OBJECT AND INHERITANCE IN PYTHON
PPTX
Python-Encapsulation.pptx
PDF
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PPT
Introduction to Python
PPT
Object Oriented Programming Concepts
PDF
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
PPTX
11 lec 11 storage class
PPSX
python Function
PPT
Type Casting in C++
PDF
Python Programming - X. Exception Handling and Assertions
PDF
Python Programming - V. Sequences (List and Tuples) and Dictionaries

More Related Content

PDF
Python libraries
PPTX
Chapter 05 classes and objects
PPTX
Python OOPs
PPTX
Class, object and inheritance in python
PPTX
Object oriented programming in python
PPTX
Chapter 07 inheritance
PPTX
Object Oriented Programming in Python
PPTX
Python – Object Oriented Programming
Python libraries
Chapter 05 classes and objects
Python OOPs
Class, object and inheritance in python
Object oriented programming in python
Chapter 07 inheritance
Object Oriented Programming in Python
Python – Object Oriented Programming

What's hot

PPTX
Python-Classes.pptx
PPT
Oops ppt
PPTX
Introduction to python
PDF
Zero to Hero - Introduction to Python3
PPTX
OOP concepts -in-Python programming language
PPTX
Python Libraries and Modules
PPTX
6-Python-Recursion PPT.pptx
PPTX
Applications of Machine Learning
PPTX
Python-Inheritance.pptx
PDF
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
PPTX
CLASS OBJECT AND INHERITANCE IN PYTHON
PPTX
Python-Encapsulation.pptx
PDF
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PPT
Introduction to Python
PPT
Object Oriented Programming Concepts
PDF
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
PPTX
11 lec 11 storage class
PPSX
python Function
PPT
Type Casting in C++
Python-Classes.pptx
Oops ppt
Introduction to python
Zero to Hero - Introduction to Python3
OOP concepts -in-Python programming language
Python Libraries and Modules
6-Python-Recursion PPT.pptx
Applications of Machine Learning
Python-Inheritance.pptx
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
CLASS OBJECT AND INHERITANCE IN PYTHON
Python-Encapsulation.pptx
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
Introduction to Python
Object Oriented Programming Concepts
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
11 lec 11 storage class
python Function
Type Casting in C++

Viewers also liked

PDF
Python Programming - X. Exception Handling and Assertions
PDF
Python Programming - V. Sequences (List and Tuples) and Dictionaries
PDF
Python Programming - XIII. GUI Programming
PDF
Python Programming - XI. String Manipulation and Regular Expressions
PDF
Python Programming - I. Introduction
PDF
Python Programming - XII. File Processing
PDF
Python Programming - II. The Basics
PDF
Python Programming - VIII. Inheritance and Polymorphism
PDF
Python Programming - IX. On Randomness
PDF
Switchable Map APIs with Drupal
PDF
Python Programming - III. Controlling the Flow
PDF
Python Programming - VII. Customizing Classes and Operator Overloading
Python Programming - X. Exception Handling and Assertions
Python Programming - V. Sequences (List and Tuples) and Dictionaries
Python Programming - XIII. GUI Programming
Python Programming - XI. String Manipulation and Regular Expressions
Python Programming - I. Introduction
Python Programming - XII. File Processing
Python Programming - II. The Basics
Python Programming - VIII. Inheritance and Polymorphism
Python Programming - IX. On Randomness
Switchable Map APIs with Drupal
Python Programming - III. Controlling the Flow
Python Programming - VII. Customizing Classes and Operator Overloading

Similar to Python Programming - VI. Classes and Objects

PPTX
Object oriented programming in python
PPTX
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
PPTX
slides11-objects_and_classes in python.pptx
PPTX
Object Oriented Programming Class and Objects
PPTX
Module 3,4.pptx
PPT
07slide.ppt
PPTX
software construction and development week 3 Python lists, tuples, dictionari...
PPTX
Regex,functions, inheritance,class, attribute,overloding
PDF
OOP concepts with respected with Python
PPTX
OOSD1-unit1_1_16_09.pptx
PPTX
UNIT 3 PY.pptx - OOPS CONCEPTS IN PYTHON
PPTX
Unit-V.pptx
PPTX
Classes_and_Objects_in_Pythonoopsconcept.pptx
PDF
1_7a6f85d03f132dcd9d7592bc4643be1c_MIT6_0001F16_Lec8.pdf
PPTX
Module - 5_TB 2_Chapter 15.pptx classes and objects
PPTX
UNIT-5 object oriented programming lecture
PPTX
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
PPTX
COMP111-Week-1_138439.pptx
PPT
General OOP concept [by-Digvijay]
Object oriented programming in python
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
slides11-objects_and_classes in python.pptx
Object Oriented Programming Class and Objects
Module 3,4.pptx
07slide.ppt
software construction and development week 3 Python lists, tuples, dictionari...
Regex,functions, inheritance,class, attribute,overloding
OOP concepts with respected with Python
OOSD1-unit1_1_16_09.pptx
UNIT 3 PY.pptx - OOPS CONCEPTS IN PYTHON
Unit-V.pptx
Classes_and_Objects_in_Pythonoopsconcept.pptx
1_7a6f85d03f132dcd9d7592bc4643be1c_MIT6_0001F16_Lec8.pdf
Module - 5_TB 2_Chapter 15.pptx classes and objects
UNIT-5 object oriented programming lecture
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
COMP111-Week-1_138439.pptx
General OOP concept [by-Digvijay]

More from Ranel Padon

PDF
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
PDF
The Synergy of Drupal Hooks/APIs (Custom Module Development with ChartJS)
PDF
Batch Scripting with Drupal (Featuring the EntityFieldQuery API)
PDF
CKEditor Widgets with Drupal
PDF
Views Unlimited: Unleashing the Power of Drupal's Views Module
PDF
Web Mapping with Drupal
PDF
Power and Elegance - Leaflet + jQuery
PDF
Of Nodes and Maps (Web Mapping with Drupal - Part II)
PDF
PyCon PH 2014 - GeoComputation
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
The Synergy of Drupal Hooks/APIs (Custom Module Development with ChartJS)
Batch Scripting with Drupal (Featuring the EntityFieldQuery API)
CKEditor Widgets with Drupal
Views Unlimited: Unleashing the Power of Drupal's Views Module
Web Mapping with Drupal
Power and Elegance - Leaflet + jQuery
Of Nodes and Maps (Web Mapping with Drupal - Part II)
PyCon PH 2014 - GeoComputation

Recently uploaded

PDF
[BDD 2025 - Mobile Development] Exploring Apple’s On-Device FoundationModels
PDF
[BDD 2025 - Artificial Intelligence] Building AI Systems That Users (and Comp...
PDF
[BDD 2025 - Full-Stack Development] Agentic AI Architecture: Redefining Syste...
PDF
Open Source Post-Quantum Cryptography - Matt Caswell
PDF
ODSC AI West: Agent Optimization: Beyond Context engineering
PPTX
"Feelings versus facts: why metrics are more important than intuition", Igor ...
 
PPTX
kernel PPT (Explanation of Windows Kernal).pptx
PDF
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
PDF
Lets Build a Serverless Function with Kiro
PDF
KMWorld - KM & AI Bring Collectivity, Nostalgia, & Selectivity
PDF
Dev Dives: Build smarter agents with UiPath Agent Builder
PDF
[BDD 2025 - Mobile Development] Mobile Engineer and Software Engineer: Are we...
PDF
[BDD 2025 - Full-Stack Development] Digital Accessibility: Why Developers nee...
PPTX
MuleSoft AI Series : Introduction to MCP
PDF
Mastering Agentic Orchestration with UiPath Maestro | Hands on Workshop
PDF
DUBAI IT MODERNIZATION WITH AZURE MANAGED SERVICES.pdf
PPTX
Connecting the unconnectable: Exploring LoRaWAN for IoT
PDF
The Necessity of Digital Forensics, the Digital Forensics Process & Laborator...
PDF
5 Common Supply Chain Attacks and How They Work | CyberPro Magazine
PDF
Cybersecurity Prevention and Detection: Unit 2
[BDD 2025 - Mobile Development] Exploring Apple’s On-Device FoundationModels
[BDD 2025 - Artificial Intelligence] Building AI Systems That Users (and Comp...
[BDD 2025 - Full-Stack Development] Agentic AI Architecture: Redefining Syste...
Open Source Post-Quantum Cryptography - Matt Caswell
ODSC AI West: Agent Optimization: Beyond Context engineering
"Feelings versus facts: why metrics are more important than intuition", Igor ...
 
kernel PPT (Explanation of Windows Kernal).pptx
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
Lets Build a Serverless Function with Kiro
KMWorld - KM & AI Bring Collectivity, Nostalgia, & Selectivity
Dev Dives: Build smarter agents with UiPath Agent Builder
[BDD 2025 - Mobile Development] Mobile Engineer and Software Engineer: Are we...
[BDD 2025 - Full-Stack Development] Digital Accessibility: Why Developers nee...
MuleSoft AI Series : Introduction to MCP
Mastering Agentic Orchestration with UiPath Maestro | Hands on Workshop
DUBAI IT MODERNIZATION WITH AZURE MANAGED SERVICES.pdf
Connecting the unconnectable: Exploring LoRaWAN for IoT
The Necessity of Digital Forensics, the Digital Forensics Process & Laborator...
5 Common Supply Chain Attacks and How They Work | CyberPro Magazine
Cybersecurity Prevention and Detection: Unit 2
In this document
Powered by AI

Overview of Python programming focusing on classes and objects, covering various programming topics.

Discussion on different programming paradigms: procedural, object-oriented, functional, and multi-paradigm programming.Focus on procedure-oriented programming, its characteristics, and design approach in programming.

Introduction to object-oriented programming, emphasizing data structuring over procedures.

Key advantages of OOP such as inheritance, data hiding, and enhanced project organization.

Origins of OOP traced back to Simula and its influence on modern languages like C++ and Java.

Basics of classes and objects, including their structure and relationship.

Detailed examination of class instantiation, special attributes, constructors, destructors, and class behaviors.

Concept of composition in OOP, focusing on the attributes' references to objects of other classes.

Citations for the content and artwork used in the presentation, maintaining a spirit of educational sharing.

Python Programming - VI. Classes and Objects


[8]ページ先頭

©2009-2025 Movatter.jp