Pythonic OOP Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Tell Python to make a new type of thing.

A

class

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

Two meanings: the most basic type of thing, and any instance of some thing.

A

object

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

What you get when you tell Python to create a class.

A

instance

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

How you define a function inside a class.

A

def

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

Inside the function in a class, self is a variable for the instance/object being accessed.

A

self

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

The concept that one class can inherit traits from another class, much like how a car has wheels.

A

composition

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

A property classes have that are from composition and are usually variables.

A

attribute

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

A phrase to say that something inherits from another, as in a “salmon” is-a “fish”.

A

is-a

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

A phrase to say that something is composed of other things or has a trait, as in “a salmon has-a mouth”.

A

has-a

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

Make a class named X that is-a Y.

A

class X(Y)

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

class X has-a __init__ that takes self and J parameters.

A
class X(object):
    def \_\_ init\_\_(self, J):
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

class X has-a function named M that takes self and J parameters.

A
class X(object):
    def M(self, J):
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Set foo to an instance of class X.

A

foo = X()

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

From foo, get the M function, and call it with parameters self, J.

A

foo.M(J)

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

From foo, get the K attribute, and set it to Q.

A

foo.K = Q

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