Podcast
Questions and Answers
ما المقصود بالبرمجة الكائنية التوجه (OOP)؟
ما المقصود بالبرمجة الكائنية التوجه (OOP)؟
- أسلوب برمجي يعتمد على الدوال فقط
- أسلوب برمجي يستخدم فقط في تطبيقات الويب
- أسلوب برمجي يعتمد على العناصر والكائنات (correct)
- أسلوب برمجي يتطلب كتابة كود معقد
ما هي الخاصية الأساسية للفئة (class) في البرمجة الكائنية التوجه؟
ما هي الخاصية الأساسية للفئة (class) في البرمجة الكائنية التوجه؟
- تحتوي على متغيرات عشوائية
- تعمل كقالب لإنشاء الكائنات (correct)
- تستطيع استخدام الذاكرة العشوائية فقط
- تحدد كيفية تنفيذ البرامج الخارجية
كيف يمكن إنشاء كائن من فئة في بايثون؟
كيف يمكن إنشاء كائن من فئة في بايثون؟
- بطرق إرثية فقط
- باستخدام الكلمة المحجوزة 'object'
- بالاتصال باسم الفئة كما لو كانت دالة (correct)
- بتنفيذ وظيفة محددة داخل فئة
ما وظيفة الدالة الخاصة __init__
في بايثون؟
ما وظيفة الدالة الخاصة __init__
في بايثون؟
ما هي خاصية الوراثة (Inheritance) في البرمجة الكائنية التوجه؟
ما هي خاصية الوراثة (Inheritance) في البرمجة الكائنية التوجه؟
أي مما يلي يمثل الف polymorphism في البرمجة الكائنية التوجه؟
أي مما يلي يمثل الف polymorphism في البرمجة الكائنية التوجه؟
كيف يتم التحكم في الوصول إلى البيانات (attributes) في البرمجة الكائنية التوجه؟
كيف يتم التحكم في الوصول إلى البيانات (attributes) في البرمجة الكائنية التوجه؟
كيف يمكن الوصول إلى سمة كائن في بايثون؟
كيف يمكن الوصول إلى سمة كائن في بايثون؟
ما هو المقصود بمفهوم التجريد في البرمجة كائنية التوجه؟
ما هو المقصود بمفهوم التجريد في البرمجة كائنية التوجه؟
ما هو أحد فوائد استخدام البرمجة كائنية التوجه في بايثون؟
ما هو أحد فوائد استخدام البرمجة كائنية التوجه في بايثون؟
كيف تتعامل بايثون مع مفاتيح الوصول (Access Modifiers)؟
كيف تتعامل بايثون مع مفاتيح الوصول (Access Modifiers)؟
ما هي إحدى الطرق التي يمكن بها التحقق من صحة المدخلات عند الوصول إلى السمات؟
ما هي إحدى الطرق التي يمكن بها التحقق من صحة المدخلات عند الوصول إلى السمات؟
ما هي الميزة الرئيسية لقوائم بايثون أو القواميس أو المجموعات بهذا الشكل؟
ما هي الميزة الرئيسية لقوائم بايثون أو القواميس أو المجموعات بهذا الشكل؟
ما هو السبب وراء استخدام معالجة الاستثناءات في البرمجة كائنية التوجه؟
ما هو السبب وراء استخدام معالجة الاستثناءات في البرمجة كائنية التوجه؟
ما هو أحد الأغراض الرئيسية لمفاهيم المولدات (Generators) في بايثون؟
ما هو أحد الأغراض الرئيسية لمفاهيم المولدات (Generators) في بايثون؟
ما هو أحد العناصر الأساسية التي تعزز قابلية إعادة استخدام الكود في البرمجة كائنية التوجه؟
ما هو أحد العناصر الأساسية التي تعزز قابلية إعادة استخدام الكود في البرمجة كائنية التوجه؟
Flashcards
التجريد (Abstraction)
التجريد (Abstraction)
إخفاء التفاصيل الداخلية المعقدة لنظام ما ، وعرض المعلومات الأساسية فقط للمستخدم. تعمل فئات وأشياء البرمجة الموجهة للكائنات (OOP) كطبقة تجريد.
الوصول إلى السمات (Getting and Setting Attributes)
الوصول إلى السمات (Getting and Setting Attributes)
تُستخدم طرق الوصول إلى السمات للتحكم في كيفية الوصول إلى البيانات وتأكيد صحتها عند الضرورة.
البرمجة الموجهة للكائنات (OOP) في بايثون
البرمجة الموجهة للكائنات (OOP) في بايثون
توفر فئات وأشياء OOP طريقة لتنظيم البرنامج إلى وحدات مترابطة. وتوفر هذه الفئات خصائص وسلوكيات الكائنات.
مزايا البرمجة الموجهة للكائنات (OOP) في بايثون
مزايا البرمجة الموجهة للكائنات (OOP) في بايثون
Signup and view all the flashcards
بنية بيانات بايثون المُدمجة (Built-in Data Structures)
بنية بيانات بايثون المُدمجة (Built-in Data Structures)
Signup and view all the flashcards
معدلات الوصول (Access Modifiers)
معدلات الوصول (Access Modifiers)
Signup and view all the flashcards
معالجة الاستثناءات (Exception Handling)
معالجة الاستثناءات (Exception Handling)
Signup and view all the flashcards
الكرّارات والمُنشئات (Iterators and Generators)
الكرّارات والمُنشئات (Iterators and Generators)
Signup and view all the flashcards
برمجة موجهة للكائنات (OOP)
برمجة موجهة للكائنات (OOP)
Signup and view all the flashcards
فئة
فئة
Signup and view all the flashcards
كائن
كائن
Signup and view all the flashcards
الصفات (السمات)
الصفات (السمات)
Signup and view all the flashcards
الأساليب (الوظائف)
الأساليب (الوظائف)
Signup and view all the flashcards
المُنشئ (__init__
)
المُنشئ (__init__
)
Signup and view all the flashcards
الميراث
الميراث
Signup and view all the flashcards
التعدد الشكلي (Polymorphism)
التعدد الشكلي (Polymorphism)
Signup and view all the flashcards
Study Notes
Introduction to Object-Oriented Programming (OOP) in Python
- Object-oriented programming (OOP) is a programming paradigm built on the concept of "objects," containing both data (attributes) and code (methods) to manipulate that data.
- Python supports OOP through classes and objects, enabling modular, reusable code.
Defining Classes
- A class acts as a blueprint for creating objects, defining attributes and methods objects will possess.
- Classes are defined using the
class
keyword, followed by the class name (usually capitalized). - Example:
class Dog:
def __init__(self, name, breed): # Constructor
self.name = name
self.breed = breed
def bark(self): # Method
print("Woof!")
Creating Objects
- An object is an instance of a class. Creating an object involves calling the class name as a function.
- Example:
my_dog = Dog("Buddy", "Golden Retriever")
- This creates
my_dog
, an object of theDog
class.
Attributes and Methods
- Attributes store data associated with an object.
- Methods define actions an object can perform.
- Accessing attributes:
print(my_dog.name) # Output: Buddy
- Calling methods:
my_dog.bark() # Output: Woof!
Constructors (__init__
)
- The
__init__
method, a special constructor, is automatically called when creating a new object; it initializes object attributes.
Inheritance
- Inheritance allows creating new classes (derived) from existing ones (base).
- A derived class inherits attributes and methods from its base class.
- It can also add its own specific attributes and methods.
- Example:
class GoldenRetriever(Dog):
def __init__(self, name):
super().__init__(name, "Golden Retriever") # Call base class constructor
my_golden = GoldenRetriever("Max") # Output: No error, inherits everything
Polymorphism
- Polymorphism enables objects from different classes to be treated as objects of a common type.
- Methods sharing the same name can have different implementations in each class.
- Example:
class Cat:
def bark(self):
print("Meow!")
my_cat = Cat()
my_cat.bark() # Output: Meow
Encapsulation
- Encapsulation bundles data (attributes) and methods operating on that data within a class.
- Access to data is controlled via methods within the class, effectively hiding internal implementation details.
Getting and Setting Attributes
- Methods are used to control attribute access and validation.
Abstraction
- Abstraction simplifies complex systems by hiding internal details and presenting essential information to the user.
- Classes and objects facilitate this abstraction layer.
Python's built-in data structures and OOP
- Python's built-in structures (lists, dictionaries, tuples) are classes.
- Their methods and attributes can be leveraged.
- OOP enhances using and creating custom classes based on data structures.
Advantages of OOP in Python
- Modularity: Code organized into classes and objects promotes reusability.
- Reusability: Classes are reused within a program or across projects.
- Maintainability: Changes in one part seldom affect other parts.
- Readability: Well-structured code is more easily understood.
- Scalability: Handling complex projects is often made easier through OOP.
Access Modifiers (Optional Advanced Topic)
- Python lacks strict access modifiers (like public, private, protected).
- Conventions are used:
- Attributes and methods with a double underscore prefix (
__
) are considered “private”. - Attributes with a single leading underscore (
_
) are often treated as subject to change; a clue they're not part of the public interface.
- Attributes and methods with a double underscore prefix (
- These are primarily conventions rather than strict language rules.
Exception Handling (in OOP context)
- Exception handling within OOP allows managing errors specifically within class methods or functions.
- This approach helps handle potential issues within objects' operations.
Iterators and Generators (optional, more advanced)
- Iterators and generators, while not strictly OOP constructs, can be utilized within OOP.
- OOP principles can be applied for designing classes that manage iterations.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
تتناول هذه الدورة مقدمة شاملة في البرمجة الكائنية في لغة بايثون. تركز على تعريف الفئات وإنشاء الكائنات، مما يمكّن من كتابة كود منظم وقابل لإعادة الاستخدام.