1. Home
  2. Explore
  3. Computer Science
  4. Python OOP Course

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Python OOP Course

  • 28Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Class Basics
In Python, each data type like string or integer is actually an instance of a
.

28 questions

  1. 1
    In Python, each data type like string or integer is actually an instance of a
    _____
    .
    Hint

    Think about the keyword that appears when you check the type of any variable.

    Answer

    class

  2. 2
    To create a custom data type in Python, you define a
    _____
    .
    Hint

    Use the keyword followed by the name and a colon.

    Answer

    class

  3. 3
    The syntax to create an instance of a class is
    _____
    .
    Hint

    Think of calling the class name like a function.

    Answer

    ClassName()

  4. 4
    Attributes are assigned to an instance using the
    _____
    operator.
    Hint

    For example, item1.name = "phone" uses this operator.

    Answer

    dot

  5. 5
    The main difference between regular variables and instance attributes is that instance attributes are
    _____
    .
    Hint

    They belong to a specific object, not globally.

    Answer

    tied to an instance

  6. 6
    A function defined inside a class is called a
    _____
    .
    Hint

    It is a function that operates on an instance of the class.

    Answer

    method

  7. 7
    All methods in a class must accept at least one parameter, conventionally named
    _____
    , because Python passes the instance itself as the first argument.
    Hint

    It refers to the current instance.

    Answer

    self

  8. 8
    When you call a method on an instance, Python automatically passes the
    _____
    as the first argument.
    Hint

    The first parameter receives this.

    Answer

    object itself

  9. 9
    The special method that is automatically called when an instance is created is named
    _____
    .
    Hint

    It starts and ends with double underscores.

    Answer

    init

  10. 10
    The
    _____
    statement is used to validate that conditions are met, raising an error if not.
    Hint

    It checks a condition and optionally prints a message.

    Answer

    assert

  11. 11
    Attributes that belong to the class itself and are shared across all instances are called
    _____
    .
    Hint

    They are defined directly inside the class, outside any method.

    Answer

    class attributes

  12. 12
    When accessing an attribute on an instance, Python first looks for it at the
    _____
    level.
    Hint

    If not found there, it then looks at the class level.

    Answer

    instance

  13. 13
    The magic attribute
    _____
    returns a dictionary of all instance attributes.
    Hint

    It gives you a dict view of the object's namespace.

    Answer

    dict

  14. 14
    A method that can be called on the class itself, not on instances, is created with the
    _____
    decorator.
    Hint

    It takes cls as the first parameter.

    Answer

    @classmethod

  15. 15
    A class method receives the
    _____
    as its first argument instead of self.
    Hint

    It is conventionally named cls.

    Answer

    class

  16. 16
    A method that does not receive any implicit first argument and is defined with the
    _____
    decorator is called a static method.
    Hint

    It behaves like a regular function but is namespaced within the class.

    Answer

    @staticmethod

  17. 17
    Static methods do not receive either self or
    _____
    as an implicit first parameter.
    Hint

    They are like regular functions.

    Answer

    cls

  18. 18
    A common use of a class method is to instantiate objects from a structured data file like
    _____
    .
    Hint

    Comma Separated Values format.

    Answer

    CSV

  19. 19
    The mechanism that allows a class to reuse code from another class is called
    _____
    .
    Hint

    It creates a parent-child relationship between classes.

    Answer

    inheritance

  20. 20
    The class that is inherited from is called the
    _____
    class.
    Hint

    Also known as superclass.

    Answer

    parent

  21. 21
    When defining a child class, you specify the parent class in
    _____
    after the class name.
    Hint

    For example: class Phone(Item):

    Answer

    parentheses

  22. 22
    Using
    _____
    helps avoid duplicating code from the parent class in child classes.
    Hint

    It allows you to call parent methods.

    Answer

    super()

  23. 23
    The principle of restricting direct access to an object's attributes is called
    _____
    .
    Hint

    It protects the internal state of an object.

    Answer

    encapsulation

  24. 24
    To make an attribute read-only, you use the
    _____
    decorator on a method that returns the attribute.
    Hint

    This turns a method into a property that can be accessed like an attribute.

    Answer

    @property

  25. 25
    The concept of hiding unnecessary internal details from the user is called
    _____
    .
    Hint

    It reduces complexity for the user.

    Answer

    abstraction

  26. 26
    To create a private method that should not be called from outside the class, you prefix its name with
    _____
    .
    Hint

    The same technique used for private attributes.

    Answer

    double underscore (__)

  27. 27
    The built-in function
    _____
    works differently on strings, lists, and other objects, demonstrating polymorphism.
    Hint

    It returns length or number of items.

    Answer

    len()

  28. 28
    In OOP, the ability of different classes to respond to the same method call in their own way is called
    _____
    .
    Hint

    "Many forms" in Greek.

    Answer

    polymorphism

1 of 28
Question 1 of 28

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent