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

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

More Related Content

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

What's hot

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

Viewers also liked

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

Similar to Python Programming - VI. Classes and Objects

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

More from Ranel Padon

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

Recently uploaded

PDF
[BDD 2025 - Full-Stack Development] Agentic AI Architecture: Redefining Syste...
PPTX
"Feelings versus facts: why metrics are more important than intuition", Igor ...
 
PDF
Agentic Intro and Hands-on: Build your first Coded Agent
PDF
10 Best Automation QA Testing Software Tools in 2025.pdf
PDF
Transforming Supply Chains with Amazon Bedrock AgentCore (AWS Swiss User Grou...
PDF
The partnership effect: Libraries and publishers on collaborating and thrivin...
PDF
ODSC AI West: Agent Optimization: Beyond Context engineering
PDF
How Much Does It Cost to Build an eCommerce Website in 2025.pdf
PDF
5 Common Supply Chain Attacks and How They Work | CyberPro Magazine
PDF
Transcript: The partnership effect: Libraries and publishers on collaborating...
PDF
"DISC as GPS for team leaders: how to lead a team from storming to performing...
 
PDF
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
PPTX
Guardrails in Action - Ensuring Safe AI with Azure AI Content Safety.pptx
PPTX
UFCD 0797 - SISTEMAS OPERATIVOS_Unidade Completa.pptx
PDF
Cheryl Hung, Vibe Coding Auth Without Melting Down! isaqb Software Architectu...
PDF
Dev Dives: Build smarter agents with UiPath Agent Builder
PDF
Mulesoft Meetup Online Portuguese: MCP e IA
PDF
[BDD 2025 - Mobile Development] Exploring Apple’s On-Device FoundationModels
PDF
Cybersecurity Prevention and Detection: Unit 2
PDF
How Much Does It Cost To Build Software
[BDD 2025 - Full-Stack Development] Agentic AI Architecture: Redefining Syste...
"Feelings versus facts: why metrics are more important than intuition", Igor ...
 
Agentic Intro and Hands-on: Build your first Coded Agent
10 Best Automation QA Testing Software Tools in 2025.pdf
Transforming Supply Chains with Amazon Bedrock AgentCore (AWS Swiss User Grou...
The partnership effect: Libraries and publishers on collaborating and thrivin...
ODSC AI West: Agent Optimization: Beyond Context engineering
How Much Does It Cost to Build an eCommerce Website in 2025.pdf
5 Common Supply Chain Attacks and How They Work | CyberPro Magazine
Transcript: The partnership effect: Libraries and publishers on collaborating...
"DISC as GPS for team leaders: how to lead a team from storming to performing...
 
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
Guardrails in Action - Ensuring Safe AI with Azure AI Content Safety.pptx
UFCD 0797 - SISTEMAS OPERATIVOS_Unidade Completa.pptx
Cheryl Hung, Vibe Coding Auth Without Melting Down! isaqb Software Architectu...
Dev Dives: Build smarter agents with UiPath Agent Builder
Mulesoft Meetup Online Portuguese: MCP e IA
[BDD 2025 - Mobile Development] Exploring Apple’s On-Device FoundationModels
Cybersecurity Prevention and Detection: Unit 2
How Much Does It Cost To Build Software
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