OOP in Python Flashcards

1
Q

Object-oriented programming

A

A programming paradigm based on “objects,” which contain state (attributes) and behavior (methods)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Object对象

A

A collection of structured data along with the operations that can be performed on that data. An object is one instance of a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Class类

A

A template or blueprint used to create objects of a specific data type. Defines what concrete objects will look like.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Instance实例

A

One particular object of a certain data type/class. Follows the format defined by its class, and has specific, individual state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

State状态

A

A generic term for the data that an object “knows” at one point in time. Usually, state can change over time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Attribute属性

A

A named property of a class. Attributes are used to keep track of state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Behavior行为

A

A generic term for what an object can “do.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Method方法

A

A function that is defined inside of a class. Methods are usually used to describe behavior.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Constructor构造函数

A

A method used when creating objects. Usually initializes an object’s attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

__init__

A

Name of the method used by Python as the constructor. Pronounced “dunder init.” One of many “dunder” (double underscore) methods that are reserved by Python for specific tasks. Because __init__ is so common, the “dunder” is often dropped in spoken conversation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

self

A

The conventional name for a parameter that refers to an instance itself within a method of a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Module

A

Any .py file that contains functions, classes, variables, and/or other runnable code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Package

A

A collection of modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Inheritance继承

A

A class relationship in which one class inherits attributes and behavior from another class. is-a relationship

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Composition组合

A

A class relationship in which a class references other classes as instance variables and makes use of their methods and attributes. has-a relationship

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Parent class

A

A class that contains variables and methods that can be inherited to other classes(base class, super class)

17
Q

Child class

A

A class that contains its own variables and methods but also inherits the variables and methods from a parent class(derived class, sub class)

18
Q

One-to-one

A

One composite object is associated with one component object, which means a single instance(has one)

19
Q

One-to-many

A

One composite object is associated with a collection of component objects, which means a list of instance.(has many)

20
Q

Software design pattern

A

Reusable patterns commonly used to solve problems. Usually describes how classes and functions are structured and used. Usually conceptual and language-agnostic.

21
Q

Iterator

A

A class whose responsibility is to know how to iterate through an object.

22
Q

Factory

A

A class or method whose responsibility is to create instances of some class.

23
Q

Adapter

A

A class whose responsibility is to help two other classes communicate with each other.

24
Q

Observer

A

A class whose responsibility is to watch for changes over many objects, and notify many objects when changes happen.

25
Q

Decorator

A

A class or method whose responsibility is to dynamically alter and extend the behavior of a function or class.

26
Q

Strategy

A

A class whose responsibility is to represent an algorithm.

27
Q

Wrapper function

A

A function whose responsibility is to “wrap” another function, or call another function within itself

28
Q

Decorator

A

In Python, a wrapper function applied using decorator syntax

29
Q

Wrapped function

A

In the context of a wrapper function, the function that is being extended

30
Q

Static method

A

A method that does not depend on an instance, and does not access instance or class variables. Essentially a regular function that happens to be stored in a class primarily for namespace purposes.

31
Q

Class method

A

A method that receives a reference to the class itself. This method does not depend on an instance, and cannot access instance variables or methods.