COMPUTER SCIENCE CAFÉ
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
PYTHON | OBJECT ORIENTED PROGRAMMING​
ON THIS PAGE
SECTION 1 | SYNTAX ERROS
SECTION 2 |  RUNTIME ERRORS

SECTION 3 | TRY AND EXCEPT
​
ALSO IN THIS TOPIC
 GETTING STARTED 

 VARIABLES AND DATA TYPES
OPERATORS 
SELECTION 

 ITERATION
 ARRAYS
 FUNCTIONS AND PROCEDURES  
 FORMATTING DATA 
 ERROR CHECKING
YOU ARE HERE | OBJECT ORIENTED PROGRAMMING 
Picture
COMING SOON | PAGE UNDER DEVELOPMENT
WHY OBJECT ORIENTED PROGRAMMING
In the functions and procedures section of learning Python we looked at procedural programming. When you create a program using functions and procedures, your program soon gets big and you have to pass and receive values from one function to the other, your code soon becomes a matrix that makes it difficult for you to keep track of the flow of your program. This is often called spaghetti code, where and values are being passed forward, backward and there are lots of interdependencies all over your code, if you change one thing then you need to remember to change it somewhere else in your code - nightmare!. However Object Oriented Programming helps reduce this problem.
WHAT IS OBJECT ORIENTED PROGRAMMING
Object Oriented Programming provides a way to decompose your program and create a blue print for objects/actions/sections needed. These blue prints are called a class, within the class you have functions, functions within a class are referred to as methods. Variables within the class with a self. prefix are known as attributes. By using the class name methods and attributes can be used throughout your program without the issues you would otherwise face with local and global variables and the passing of parameters.
THE FOUR 4 PILLARS OF OOP
ENCAPSULATION
Grouping related variables and items together to help simplify your program by encapsulating them in one place, in turn this makes it easy to re-use/call variables.
ABSTRACTION
Is a process of filtering out only the details needed, reducing complexity and interdependencies within your code. Hiding or removing unnecessary information.
INHERITTANCE
Is the process of allowing multiple sections of code to inherit/use attributes from another piece of code. Rather that duplication or code, if one section of your code needs the same values as another is already using the process of inheritance provides an efficient method of doing this. For example if each page in your GUI project has the same styling, then you can inherent the styles from a style sheet rather than re-coding the styles each time you create a new page.
POLYMORPHISM
Polymorphism means 'Many Forms' Poly(Many) Morphism(Forms). It is a method that helps to reduce the need for long if statements, this is done by enabling rendering/relationships depending on the type of object you are referencing to rather than the attributes of the object.
SECTION 1 | ATTRIBUTES AND METHODS
Picture
In OOP, a class is like a blueprint, and an object is an instance of that blueprint. The class can have attributes (characteristics or properties) and methods (functions or behaviours).

Attributes:
Attributes are variables that store data for an instance or for the class itself.

Instance Variables: These are variables that are unique to each instance of the class. They are defined within methods and are accessed using the self keyword.
​
Picture
NAVIGATION
​GETTING STARTED | Downloading Python and creating Hello World
VARIABLES AND DATA TYPES | Storing data in variables
OPERATORS | Performing calculations and comparisons
SELECTION | Using IF statements
ITERATION | Using FOR Loops and WHILE Loops
ARRAYS | Getting started with Lists
FUNCTIONS AND PROCEDURES | Breaking your code into logical sections
FORMATTING DATA | Further data manipulation
ERROR CHECKING | Using Try and Except to catch user errors
OBJECT ORIENTED PROGRAMMING | Getting to grips with OOP
Picture
SUGGESTIONS
We would love to hear from you
SUBSCRIBE 
To enjoy more benefits
We hope you find this site useful. If you notice any errors or would like to contribute material then please contact us.