What is OOP (Object Oriented Programming)?
Object-Oriented Programming (OOP) is a programming approach that organizes code into reusable software entities called objects. These objects encapsulate data (attributes) and the functions (methods) that operate on that data
What is modularity?
Modularity is the concept of breaking down a complex system into smaller, independent, and interchangeable parts called modules
What is Procedural programming?
Procedural programming is a programming paradigm that uses procedures (or functions and subroutines) to perform specific tasks, breaking down a program into a series of steps and instructions
What is Inheritance?
The capabilities of a class to derive properities or characteristics from another class is known as inheritance. The properties of Class A can be shared or inherited by another Class name B without the need to write all of Class A propeties to B agian. This reduce redundancy in code.
What is Encapsulation?
Encapsulation is the wrapping of data under a single unit or keeping data safe inside an object, and it can only be changeed in control ways. In Encapsulation Class A cannot accesss the properites or data in Class B. The data in Class A is hidden from Class B which is why it’s also caled data-hiding.
What is Data Abstraction?
Data abstraction shows the essential information while hiding the rest. it include providing only essential information to the outside world and hiding the background implementation
A computer does two thing, what are they?
A computer simply processes calculations and stores them
What were the earliest set of computers?
The earliest set of computers were set to be fixed prorammed machines or computers meaning they were only made for specific purposes typicall for mathematical calculation. An example of a fixed programmed machine today is the calculaor
What is a class?
A class is a
blueprint
for creating objects. It defines a structure that binds both
data
(attributes) and
methods
(functions) into a single unit
What is the truly first Modern Computer?
Manchest Mark ii. A stored program computer
WHat is flow of control
Is the order in which a program execute instructions or statement by using conditionals and loops.
What is one weakness of python?
Weakness in static semantic checking so it’s not optimal for programs with high reliability constraints.
What is an Object
An object is an
instance
of a class. It represents individual entities that have
state
(attributes)
and
behavior
(methods). Each object created from the same class will have unique values for
its attributes but share the same structure and behavior
waht is the purpose of the init function?
_init__ function in Python is to initialize a new object when an instance of a class is created. It acts as the constructor for the class,
What is the purpose of the .self function in python
n Python, self is a convention used within class methods to refer to the instance of the class on which the method is being called
What are methods?
Functions defined within a class to represent behaviors
What are constructors in python?
A special method within a class that is automatically called when an object of that
class is created
What are attributes?
Attributes
are like the characteristics or properties of an object. They define what an object is
and what it can do. There are two main types
Define the instance Attribute?
Instance Attributes:
Belong to individual objects.
Defined within the
__init__
method.
Accessed using
self.attribute_name
An instance attribute is a variable that belongs exclusively to a specific instance (object) of a class. Unlike class attributes, which are shared by all instances of a class, instance attributes store data that is unique to each individual object.
What are class attribute?
Shared by all instances of a class.
Defined directly within the class.
Accessed using
ClassName.attribute_name
or
self.attribute_name
.
What is an instance method?
Belong to individual objects.
Take
self
as the first parameter.
Can access both instance and class attributes
An instance method is a function that is defined within a class and operates on a specific object (an “instance”) of that class.
What is a class method?
Belong to the class itself.
Decorated with the
Take
@classmethod
decorator.
cls
as the first parameter.
Can only access class attributes.
A class method in Python is a type of method that operates on the class itself, rather than on an instance of the class. It is defined within a class and is typically used to interact with class-level attribute
Why do we use methods?
Encapsulation:
Methods help encapsulate the behavior of an object within the class,
making it more modular and easier to maintain.
Reusability:
You can define methods that can be used by multiple objects of the
same class, promoting code reusability.
Abstraction:
Methods allow you to hide the implementation details of an object’s
behavior, providing a simpler interface for users
What is a getter method?
A getter method is used to retrieve the value of an attribute