National Digital LMS
Module 2: Core Competencies

Chapter 3: Spreadsheet Mastery in MS Excel

Cells, ranges, formula bar, SUM, AVERAGE, IF functions, and data charts.

20 mins read Pages 39 - 57
Bilingual Learning (English & اردو) Class 12 / HSSC-II Level

Chapter 3: Object Oriented Programming Using Python (Page 33 – 44)

تیسرا باب: پائتھن میں آبجیکٹ اورینٹڈ پروگرامنگ

Object-Oriented Programming (OOP) is a software engineering paradigm that models software systems around real-world entities combining data state (attributes) and behavioral operations (methods) inside modular capsules called classes. This chapter covers procedural limitations, class and object anatomy, the __init__() constructor, the self reference parameter, and the 4 fundamental pillars: Encapsulation, Inheritance, Polymorphism, and Abstraction.

آبجیکٹ اورینٹڈ پروگرامنگ (OOP) جدید سافٹ ویئر ڈویلپمنٹ کا سب سے اہم طریقہ ہے جس میں پروگرام کو حقیقی دنیا کی چیزوں (انسان، گاڑی، بینک اکاؤنٹ) کے ماڈل پر ڈیزائن کیا جاتا ہے۔ اس میں ڈیٹا کی خصوصیات (Attributes) اور ان پر ہونے والے کاموں (Methods) کو کلاسز کے اندر یکجا کر دیا جاتا ہے۔ اس باب میں کلاس اور آبجیکٹ کی ساخت، کنسٹرکٹر، اور او او پی کے چاروں بنیادی ستونوں کی گہری تفہیم شامل ہے۔
Visual Architecture: Python Class Blueprint vs Physical Memory Objects تصویری خاکہ
Object Oriented Programming in Python (او او پی کی تفہیم) Classes, Objects, and the 4 Pillars | Chapter 3 (Pages 33-44) THE BLUEPRINT (کلاس کا نقشہ) class Student: ATTRIBUTES / FIELDS (خصوصیات): • name: str ("Ali") • roll_no: int (101) • __marks: float (88.5) [Private/Encapsulated] METHODS / ACTIONS (افعال و کام): • __init__(self, name, roll_no, marks) • get_percentage(self) • display_profile(self) Stored on disk as source code template instantiate آبجیکٹ بنانا OBJECT 1: student1 = Student("Ali", 101, 88.5) Allocated in RAM at Address: 0x7ffeef12a student1.name = "Ali Ahmad" student1.roll_no = 101 student1.get_percentage() → 88.5% OBJECT 2: student2 = Student("Fatima", 102, 94.0) Allocated in RAM at Address: 0x7ffeef98b student2.name = "Fatima Noor" student2.roll_no = 102 student2.get_percentage() → 94.0%
Comprehensive Textbook Learning Material (تفصیلی تعلیمی مواد)
Full Syllabus Coverage • BISE Punjab
1 1. Procedural vs. Object-Oriented Paradigm
۱. پروسیجرل بمقابلہ آبجیکٹ اورینٹڈ پروگرامنگ
English Theoretical Concept & Technical Breakdown:
- **Procedural Programming (e.g., C, early Python scripts):** Programs are structured as a linear sequence of functional steps manipulating global and local variables. As codebases expand beyond thousands of lines, global data becomes vulnerable to accidental corruption from unrelated functions.
- **Object-Oriented Programming (OOP):** Solves procedural vulnerability by binding data attributes and functions together into a cohesive entity. Data cannot be modified arbitrarily from outside; access is controlled via explicit methods. Code reusability is dramatically enhanced through inheritance.
آسان اردو میں مکمل اور تفصیلی وضاحت:
- **پروسیجرل پروگرامنگ:** اس میں کوڈ اوپر سے نیچے فنکشنز کی صورت میں چلتا ہے۔ تمام متغیرات (Variables) کھلے ہوتے ہیں جنہیں کوئی بھی فنکشن غلطی سے تبدیل کر سکتا ہے۔ بڑے پراجیکٹس میں یہ طریقہ انتہائی غیر محفوظ اور الجھن والا بن جاتا ہے۔
- **آبجیکٹ اورینٹڈ پروگرامنگ (OOP):** اس میں ڈیٹا اور فنکشنز کو ایک مضبوط دیوار (کلاس) کے اندر بند کر دیا جاتا ہے۔ باہر کا کوئی غلط کوڈ براہ راست ڈیٹا کو تبدیل نہیں کر سکتا۔ اس سے کوڈ کو بار بار استعمال کرنا اور محفوظ رکھنا آسان ہو جاتا ہے۔
Real-World Student Analogy (روزمرہ زندگی سے آسان فہم مثال):
In English: Procedural is having medical records written on open clipboards where any visitor can scribble on them. OOP is keeping records in an electronic database where only authenticated doctors can view or update patient vitals.
پروسیجرل پروگرامنگ کھلی کاپی جیسی ہے جس میں کوئی بھی آ کر کچھ بھی لکھ دے۔ او او پی ایک محفوظ ڈیجیٹل فائل ہے جس میں صرف پاس ورڈ والا ڈاکٹر ہی ریکارڈ دیکھ یا بدل سکتا ہے۔
BISE Punjab Board Examination Tip (اہم امتحانی نکات):
Common Short Question: "What are the advantages of OOP over procedural programming?"
2 2. Anatomy of a Class: Attributes, Methods & `__init__()`
۲. کلاس کا مکمل پوسٹ مارٹم: فیلڈز، میتھڈز اور کنسٹرکٹر
English Theoretical Concept & Technical Breakdown:
- **Class (Blueprint):** Defined using the `class` keyword. Does not allocate physical data storage until instantiated.
- **Object (Instance):** An active allocation in RAM possessing its own distinct state.
- **The Constructor (`__init__`):** A double-underscore magic method invoked automatically by the Python runtime the instant memory is allocated for a new object. Used to initialize instance variables.
- **The `self` Keyword:** An explicit reference to the current object instance executing the method, ensuring `self.marks` updates that specific student's record, not another student's.
آسان اردو میں مکمل اور تفصیلی وضاحت:
- **کلاس:** ایک سانچہ یا نقشہ جو بتاتا ہے کہ آبجیکٹ کیسا ہوگا (جیسے بینک اکاؤنٹ کا فارم)۔
- **آبجیکٹ:** اس کلاس کا اصلی زندہ وجود جو کمپیوٹر کی میموری میں بنتا ہے (جیسے علی کا ذاتی بینک اکاؤنٹ جس کا بیلنس ۵۰،۰۰۰ روپے ہے)۔
- **کنسٹرکٹر (`__init__`):** یہ پائتھن کا خاص خودکار فنکشن ہے جو آبجیکٹ بنتے ہی خود بخود چل جاتا ہے تاکہ اس کی ابتدائی معلومات سیٹ کر سکے۔
- **سیلف (`self`):** یہ اسی موجودہ آبجیکٹ کا پتہ ہوتا ہے تاکہ پائتھن کو معلوم ہو کہ کس مخصوص طالب علم کے نمبر بدلے جا رہے ہیں۔
Real-World Student Analogy (روزمرہ زندگی سے آسان فہم مثال):
In English: A cookie cutter is the Class. The 100 individual chocolate chip cookies baked using that cutter are the Objects.
بسکٹ بنانے والا سانچہ کلاس ہے، اور اس سے بننے والے الگ الگ بسکٹ آبجیکٹس ہیں۔
BISE Punjab Board Examination Tip (اہم امتحانی نکات):
Board Question: "What is the function of the __init__ method in a Python class?"
3 3. The Four Pillars of OOP in Python
۳. آبجیکٹ اورینٹڈ پروگرامنگ کے چار بنیادی ستون
English Theoretical Concept & Technical Breakdown:
1. **Encapsulation (ڈیٹا چھپانا):** Restricts direct outside access to critical attributes. In Python, prefixing an attribute with double underscores (e.g. `self.__balance`) makes it private. Access is mediated through **Getter** and **Setter** methods that can validate data before updating.
2. **Inheritance (وراثت):** Allows a new class (Child / Derived) to absorb attributes and methods from an existing class (Parent / Base) using `class ChildClass(ParentClass):`. The `super().__init__()` call delegates initialization up to the parent.
3. **Polymorphism (کثیر اشکالی):** "Many forms." Allows child classes to provide specialized implementations of methods defined in their parent class (Method Overriding).
4. **Abstraction (تجرید):** Hiding complex low-level algorithm details behind simple interface commands.
آسان اردو میں مکمل اور تفصیلی وضاحت:
۱. **این کیپسولیشن (Encapsulation):** اہم ڈیٹا کو چھپانا تاکہ باہر سے کوئی خراب نہ کر سکے۔ پائتھن میں متغیر کے نام سے پہلے دو انڈرسکور (`__`) لگا کر اسے پرائیویٹ بنایا جاتا ہے۔
۲. **وراثت (Inheritance):** نئی کلاس کو پرانی کلاس کی تمام خصوصیات بغیر دوبارہ کوڈ لکھے عطا کرنا۔ جیسے `CSStudent` کلاس `Student` کلاس سے سب کچھ ورثے میں لے لیتی ہے۔
۳. **پولیمورفزم (Polymorphism):** ایک ہی نام کے فنکشن کا مختلف حالات میں مختلف انداز میں کام کرنا (Method Overriding)۔
۴. **تجرید (Abstraction):** اندرونی پیچیدگیوں کو چھپا کر صرف آسان بٹن مہیا کرنا۔
Real-World Student Analogy (روزمرہ زندگی سے آسان فہم مثال):
In English: Encapsulation is like a medical pill capsule: The bitter chemical medicine is safely sealed inside. Polymorphism is like pressing a "Play" button on your computer: It plays a song if you are in Spotify, or plays a movie if you are in VLC.
این کیپسولیشن دوائی کے کیپسول کی مانند ہے جس کا کڑوا پاؤڈر اندر محفوظ بند ہوتا ہے۔ پولیمورفزم ریموٹ کنٹرول کے "پاور" بٹن جیسا ہے جو ٹی وی کے لیے ٹی وی آن کرتا ہے اور اے سی کے لیے اے سی چلاتا ہے۔
BISE Punjab Board Examination Tip (اہم امتحانی نکات):
High Probability 8-Mark Question: "Explain Encapsulation, Inheritance, and Polymorphism in Python with syntax and a complete program."
Looking for the official textbook pages?

Jump directly to pages 39 - 57 in the embedded streaming viewer.

PCTB Official Textbook - Chapter 3 Start Page: 39
Download
Protected Stream Proxy: Direct hotlinking is blocked. Byte-ranges are streamed dynamically.
Class 12 Chapters