📘 Part 1: Introduction to Object Orientation
✅ Why use Object Orientation?
📘 Part 2: Main Principles of OOP
-
Encapsulation → hiding details
-
Inheritance → child class gets features of parent class
-
Polymorphism → same function, different behavior
-
Abstraction → show only important things, hide details
-
Classes & Objects
📘 Part 3: Python Basics Refresher
✅ Data Structures
Structure |
Written With |
Ordered? |
Changeable? |
Allows Duplicates? |
Example |
Tuple |
() |
Yes |
❌ No |
✅ Yes |
(1, 2, "Hi") |
List |
[] |
Yes |
✅ Yes |
✅ Yes |
[1,2,2,3] |
Set |
{} |
No |
✅ Yes |
❌ No |
{1,2,3} |
Dictionary |
{key:val} |
Yes |
✅ Yes |
Keys ❌ dupes, Values ✅ |
{"A":10, "B":20} |
✅ Variables
-
Must start with a letter or _
-
Cannot start with number
-
Case-sensitive (Age ≠ age
)
-
Use meaningful names (student_age
✔ vs x
✘)
✅ Operators
✅ Indentation in Python
if age >= 18:
print("Adult")
else:
print("Child")
📘 Part 4: Control Flow
-
Sequence → run line by line
-
Selection (if/else) → decision-making
-
Repetition (loops) → repeat tasks
-
for loop
→ repeat fixed times
-
while loop
→ repeat until condition false
-
break
→ exit loop early
-
continue
→ skip one loop step
📘 Part 5: Functions
def greet(name):
return "Hello " + name
print(greet("Faaz"))
📘 Part 6: Sorting & Searching
-
Bubble Sort → repeatedly swap until sorted (slow for big data).
-
Selection Sort → pick smallest, put in front.
-
Insertion Sort → place each new item in correct place.
-
Merge & Quick Sort → faster, used in real life.
📘 Part 7: Advanced Math
-
Factorial → 5! = 5×4×3×2×1 = 120
-
Permutations (order matters) → number of ways to arrange items
-
Combinations (order doesn’t matter) → number of ways to choose items
📘 Part 8: OOP in Python
class Dog:
def __init__(self, name): # constructor
self.name = name # attribute
def bark(self): # method
print(self.name + " says Woof!")
dog1 = Dog("Buddy") # create object
dog1.bark() # Output: Buddy says Woof!
📘 Part 9: Flowcharts & Problem Solving
-
Flowcharts help visualize logic.
-
Example: A game where user inputs a number, computer generates random number → compare → check win/loss.
🔹 Cohesion (togetherness inside a class/module)
-
Meaning: How strongly related the functions inside one class are.
-
High Cohesion = everything in the class is focused on one clear job.
-
Low Cohesion = class does many unrelated jobs → confusing & hard to maintain.
✅ Example:
# High Cohesion (Payment related only)
class PaymentProcessor:
def validate_payment(self): pass
def process_payment(self): pass
def send_receipt(self): pass
This class only handles payment-related work → high cohesion.
# Low Cohesion (Mixing many jobs)
class Utility:
def send_email(self): pass
def calculate_salary(self): pass
def draw_graph(self): pass
Here, one class is trying to do too many different things → low cohesion.
🔹 Coupling (connections between classes/modules)
-
Meaning: How much one class depends on another class.
-
Tightly Coupled = classes know too much about each other → hard to change one without breaking the other.
-
Loosely Coupled = classes depend only on essential information → flexible and easy to maintain.
✅ Example:
# Loose Coupling (better)
class PaymentProcessor:
def process(self, payment_method):
payment_method.pay()
class CreditCard:
def pay(self): print("Paying with Credit Card")
class PayPal:
def pay(self): print("Paying with PayPal")
processor = PaymentProcessor()
processor.process(PayPal()) # Can easily swap methods
Here, PaymentProcessor
only needs to know that payment_method
has a pay()
function.
It doesn’t care how PayPal or CreditCard works inside → loosely coupled.
# Tight Coupling (bad)
class PaymentProcessor:
def pay_with_creditcard(self): pass
def pay_with_paypal(self): pass
If you add a new method (e.g., Bitcoin), you must modify the class.
This makes the system hard to extend → tightly coupled.
🔹 Rule of Thumb
👉 Good software should be Highly Cohesive + Loosely Coupled:
That’s how professional software is easier to read, test, reuse, and maintain.
🔹 What is Abstraction?
Abstraction = show only important details and hide the unnecessary ones.
👉 Example: When you drive a car, you just use the steering wheel & pedals.
You don’t see the engine’s wires or fuel injection system — that’s hidden.
🔹 Types of Abstraction in OOP
1. Classification Abstraction
-
Meaning: Grouping similar objects into classes.
-
Analogy: Labrador, Poodle, Bulldog → all grouped as Dog.
-
Focus: Looks at similarities.
class Dog:
def __init__(self, breed):
self.breed = breed
dog1 = Dog("Labrador")
dog2 = Dog("Poodle")
Here, Dog is a general class for all breeds.
2. Generalization Abstraction
-
Meaning: Creating parent-child relationships (inheritance).
-
Analogy: "Mammal" is a general class → Dog, Cat, Horse are children.
-
Focus: Top-down → from general → specific.
class Animal: # Parent
def breathe(self): print("Breathing")
class Dog(Animal): # Child
def bark(self): print("Woof!")
d = Dog()
d.breathe() # Inherited
d.bark()
Here, Dog
inherits general features of Animal
.
3. Aggregation Abstraction (weak “has-a” relation)
-
Meaning: One object contains another, but parts can live independently.
-
Analogy: A Car has a Radio. The Radio can exist without the Car.
class Radio:
def play(self): print("Playing music")
class Car:
def __init__(self, radio):
self.radio = radio # "has-a" relation
my_radio = Radio()
my_car = Car(my_radio)
my_car.radio.play()
4. Composition Abstraction (strong “part-of” relation)
class Room:
def __init__(self, name):
self.name = name
class House:
def __init__(self):
self.rooms = [Room("Living"), Room("Bedroom")]
h = House()
for r in h.rooms:
print(r.name)
Here, Room
objects exist only because the House
exists.
5. Behavioral Abstraction
-
Meaning: Hiding implementation details of methods, only showing what they do.
-
Analogy: You click “Print” → you don’t know if it’s laser/inkjet, but you get output.
-
Focus: Method signatures, not how they work inside.
class Printer:
def print_document(self): # behavior is abstract
raise NotImplementedError("Subclasses must implement")
class LaserPrinter(Printer):
def print_document(self):
print("Printing with laser...")
class InkjetPrinter(Printer):
def print_document(self):
print("Printing with inkjet...")
p = InkjetPrinter()
p.print_document()
Here, print_document()
hides details, but each printer implements it differently.
🔹 Summary
Type |
Focus |
Example |
Classification |
Grouping similar objects |
Dogs → Dog class |
Generalization |
Parent-child hierarchy |
Animal → Dog, Cat |
Aggregation |
Weak "has-a" |
Car has a Radio |
Composition |
Strong "part-of" |
House has Rooms |
Behavioral |
Hide method details |
Printer with different implementations |
.
🔹 Classification
-
Meaning: Grouping similar objects into classes based on common properties.
-
Approach: Bottom-Up → start from specific objects → group them.
-
Question it answers: “What category does this object belong to?”
✅ Example:
-
Labrador, Poodle, Bulldog → all grouped as Dog.
-
Cat, Tiger, Lion → all grouped as Cat family.
# Classification Example
class Dog:
def __init__(self, breed):
self.breed = breed
dog1 = Dog("Labrador")
dog2 = Dog("Poodle")
print(dog1.breed) # Labrador
Here, classification means: we group similar objects → all are Dogs.
🔹 Generalization
-
Meaning: Create hierarchies where specific classes inherit from general ones.
-
Approach: Top-Down → start from general concept → create specialized ones.
-
Question it answers: “What is the more general concept that covers this?”
✅ Example:
# Generalization Example
class Animal: # General (parent)
def breathe(self): print("Breathing")
class Dog(Animal): # Specific (child)
def bark(self): print("Woof!")
class Cat(Animal): # Specific (child)
def meow(self): print("Meow!")
d = Dog()
d.breathe() # Inherited from Animal
d.bark()
Here, generalization means: we create a general Animal
class → and let Dog & Cat inherit from it.
🔹 Key Differences (Side-by-Side)
Feature |
Classification |
Generalization |
Definition |
Grouping similar objects into categories |
Building parent-child relationships |
Direction |
Bottom-Up (from specific → category) |
Top-Down (from general → specialized) |
Focus |
Similarities among objects |
Hierarchies & inheritance |
Example |
Labrador + Poodle + Bulldog = Dog class |
Dog, Cat, Horse → inherit from Animal class |
Question |
“What category is this object in?” |
“What general concept does this belong to?” |
🔹 Real-Life Analogy
-
Classification:
-
Generalization:
✅ In short:
🃏 Flashcards for OOP with Python
🔹 Beginner (Basics)
Q1: What is Object Orientation?
A1: A way of designing programs around objects (real-world entities) that have attributes (data) and methods (behavior).
Q2: What is a Class?
A2: A blueprint/template for creating objects.
Q3: What is an Object?
A3: An instance of a class (real thing created from the blueprint).
Q4: What are the 4 main principles of OOP?
A4: Encapsulation, Inheritance, Polymorphism, Abstraction.
Q5: What is the difference between Attributes and Methods?
A5: Attributes = variables (data of object). Methods = functions (behavior of object).
🔹 Encapsulation & Abstraction
Q6: What is Encapsulation?
A6: Hiding internal details of a class and controlling access using getters & setters.
Q7: Example of Encapsulation in Python?
A7:
class Bank:
def __init__(self, balance):
self.__balance = balance
def get_balance(self):
return self.__balance
Q8: What is Abstraction?
A8: Showing only necessary features, hiding the implementation details.
Q9: Types of Abstraction?
A9: Classification, Generalization, Aggregation, Composition, Behavioral.
Q10: Example of Abstraction in real life?
A10: Driving a car → you use the steering wheel (interface), but don’t see engine details.
🔹 Inheritance & Polymorphism
Q11: What is Inheritance?
A11: When a class (child) inherits attributes & methods from another class (parent).
Q12: What is Polymorphism?
A12: Same method name, different behavior depending on object.
Q13: Python Example of Polymorphism?
A13:
class Dog:
def speak(self): print("Woof!")
class Cat:
def speak(self): print("Meow!")
for animal in [Dog(), Cat()]:
animal.speak()
🔹 Cohesion & Coupling
Q14: What is High Cohesion?
A14: A class does only one job well (focused).
Q15: What is Low Coupling?
A15: Classes are independent and interact only through simple interfaces.
Q16: Ideal design principle?
A16: High Cohesion + Low Coupling → modular, reusable code.
🔹 Python Basics from PDF
Q17: List vs Tuple vs Set vs Dictionary?
A17:
-
List → ordered, mutable, allows duplicates
-
Tuple → ordered, immutable
-
Set → unordered, unique values only
-
Dictionary → key-value pairs
Q18: What is Indentation in Python?
A18: Spaces at the start of a line that define blocks of code (instead of {}
).
Q19: What does break
and continue
do in loops?
A19: break
exits loop, continue
skips current iteration.
🔹 Control Flow
Q20: Difference between Sequence, Selection, and Repetition?
A20:
-
Sequence → step-by-step execution
-
Selection → decision-making (if/else)
-
Repetition → looping (for, while)
Q21: Deterministic vs Non-Deterministic Loops?
A21:
-
Deterministic → fixed iterations (e.g., for i in range(5))
-
Non-Deterministic → unknown iterations (e.g., while user_input != "stop")
🔹 Functions & Recursion
Q22: What is a Function?
A22: A reusable block of code with name, parameters, and optional return value.
Q23: Difference between Function and Method?
A23:
Q24: What is Recursion?
A24: A function calling itself until a base case is reached.
Q25: Recursion vs Iteration?
A25:
-
Recursion → uses call stack, may risk stack overflow
-
Iteration → uses loops, more memory efficient
🔹 Algorithms
Q26: What is Bubble Sort?
A26: Repeatedly swap adjacent elements if out of order.
Q27: What is Selection Sort?
A27: Repeatedly find the minimum element and place it in order.
Q28: What is Insertion Sort?
A28: Insert each element into the correct position in sorted part.
Q29: What is Merge Sort?
A29: Divide & conquer → split list, sort halves, merge results.
Q30: What is Quick Sort?
A30: Choose a pivot, partition list, sort sublists recursively.
🔹 Math & Probability
Q31: What is Factorial?
A31: n! = n × (n-1) × ... × 1
Q32: What is a Permutation?
A32: Selection where order matters → nPk = n! / (n-k)!
Q33: What is a Combination?
A33: Selection where order does NOT matter → nCk = n! / (k!(n-k)!)
🔹 Advanced OOP in Python
Q34: What is self
in Python classes?
A34: Refers to the current object instance (needed for attributes & methods).
Q35: Why use __
(double underscore) before variable names?
A35: To make them private → accessed only through getters/setters.
Q36: What is the difference between Public, Protected, and Private attributes in Python?
A36:
-
Public → normal (name
) → accessible anywhere
-
Protected → _name
→ “internal use only” (by convention)
-
Private → __name
→ hidden, only accessible inside class
🔹 Flowcharts & Problem Solving
Q37: Why use Flowcharts for algorithms?
A37: Visual clarity, easier debugging, error detection, and communication.
Q38: Example: Game logic flashcard
Q38A: User inputs number → computer generates random → compare → if 2+ matches in 3 tries → Win.
💥 Whatsapp https://wa.link/b72px4
💥 YouTube https://www.youtube.com/channel/UCJojbxGV0sfU1QPWhRxx4-A
💥 Blog https://localedxcelcambridgeictcomputerclass.blogspot.com/
💥 WordPress https://computerclassinsrilanka.wordpress.com
💥 Facebook https://web.facebook.com/itclasssrilanka
💥 Wix https://itclasssl.wixsite.com/icttraining
💥 Web https://itclasssl.github.io/eTeacher/
💥 Medium https://medium.com/@itclasssl
💥 Quora https://www.quora.com/profile/BIT-UCSC-UoM-Final-Year-Student-Project-Guide
💥 mystrikingly https://bit-ucsc-uom-final-year-project-ideas-help-guide-php-class.mystrikingly.com/
💥 https://elakiri.com/threads/bit-ucsc-uom-php-mysql-project-guidance-and-individual-classes-in-colombo.1627048/
💥 https://bitbscucscuomfinalprojectclasslk.weebly.com/
💥 https://www.tiktok.com/@onlinelearningitclassso1
💥 https://payhip.com/eTeacherAmithafz/
💥 https://discord.gg/cPWAANKt
💥 https://6789f6ca695da.site123.me/blog
💥 https://eteacher-49046330.hubspotpagebuilder.com/join-the-best-ict-software-project-classes-in-sri-lanka
💥 https://www.tumblr.com/blog/computercoursesincolombo-blog
💥Subscribe on LinkedIn https://www.linkedin.com/build-relation/newsletter-follow?entityUrn=7072056309516304384
💥https://www.scribd.com/user/682883198/Online-Learning-IT-Class-Software-Dev
---
🚀 Join the Best BIT Software Project Classes in Sri Lanka! 🎓
Are you a BIT student struggling with your final year project or looking for expert guidance to ace your UCSC final year project? 💡 We've got you covered!
✅ What We Offer:
- Personalized project consultations
- Step-by-step project development guidance
- Expert coding and programming assistance (PHP, Python, Java, etc.)
- Viva preparation and documentation support
- Help with selecting winning project ideas
📅 Class Schedules:
- Weekend Batches: Flexible timings for working students
- Online & In-Person Options
🏆 Why Choose Us?
- Proven track record of guiding top BIT projects
- Hands-on experience with industry experts
- Affordable rates tailored for students
🔗 Enroll Now: Secure your spot today and take the first step toward project success!
📞 Contact us: https://web.facebook.com/itclasssrilanka
📍 Location: Online
🌐 Visit us online: https://localedxcelcambridgeictcomputerclass.blogspot.com/
✨ Don't wait until the last minute! Start your BIT final year project with confidence and guidance from the best in the industry. Let's make your project a success story!
---
Individual attention to all students
🎓 Final Year IT & Computer Science Students! 🚀
Get Expert Guidance for Your Degree Projects & Reports!
📍 Colombo | Moratuwa | UoM | Colombo Uni | BIT | BIT Degree | SLIIT | BSc
💡 We Specialize In:
✅ Project Proposal Writing (University-Ready)
✅ Interim Report Assistance
✅ Final Dissertation / Use Case Document Support
✅ Test Manual & Installation Guides
✅ Complete Final-Year Project System (Fully Working)
✅ Test Document Preparation
✅ Computer Studies / BIT / Software Engineering / IT / VLE Courses
👨🏫 Supervision by Experienced Software Developers & University Project Guides
📘 Covers: Java, Python, PHP, MySQL, AI, Web & Mobile Development, Machine Learning
📞 Contact Now to Book Your Slot – Limited Project Guidance Available!
🚀 **LEARN COMPUTER SCIENCE & TECH SKILLS FROM ZERO TO PRO!** 🎓💻
✨ *Future-Proof Your Career with Our Practical Courses!*
📚 **Courses We Offer:**
🎓 **ICT for School Leavers (Post O/L or A/L)**
✅ Intro to IT & Careers in ICT
✅ MS Office (Word, Excel, PowerPoint, Access)
✅ Email, Conferencing & Digital Communication
✅ Databases & Queries
✅ Intro to Python Programming
✅ Basic Graphic Design & Photo Editing
✅ Project Work: Resume, Reports, Presentations
💻 Web Development (Beginner → Intermediate)
🌐 Web Basics: HTML5, CSS3, Responsive Design
⚡ JavaScript, Forms & Validation
🖥️ Backend with PHP/Node.js + MySQL
🌟 Hosting, Domain Setup, GitHub Deployment
🎨 Optional: WordPress, Figma, Canva
📱 **Social & Digital Media Marketing**
📈 SEO, Google Ads & Content Marketing
📲 Facebook, Instagram, TikTok & YouTube Marketing
🎯 Ads Manager, Email Marketing, Analytics
🛠️ Capstone Project: Create a Real Campaign!
🖥️ **Computer Programming (Beginner → Intermediate)**
🐍 Python/Scratch Basics – Logic, Loops, Functions
👨💻 Object-Oriented Programming
🎮 Mini Projects: Games, GUIs, Databases
🤖 **Artificial Intelligence (AI) – Beginner Level**
🔍 AI Basics: History, Applications, AI vs ML
📊 Machine Learning with Python & scikit-learn
🧠 Projects: Image Recognition, Chatbots, Voice Assistant
⚖️ AI Ethics, Jobs & Future Trends
🔥 **WHY JOIN US?**
✅ Short-term, practical & career-focused training
✅ Hands-on projects & real-world applications
✅ Ideal for students, job-seekers & tech enthusiasts
📞 **Call/WhatsApp Now:** 0777337279
🌐 **Register Today & Start Your Journey in Tech!**
✨ *Limited Seats | Certificates Provided | Learn with Experts!*
💡 **Tag a Friend Who Needs This!** 🔖