Object Oriented Flashcards

1
Q

object

A

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

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

instance

A

What you get when you tell Python to create a class

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

def

A

How you define a function inside a class

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

self

A

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

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

inheritance

A

The concept that one class can inherit traits from another class, much like you and your parents

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

composition

A

The concept that a class can be composed of other classes as parts, much like how a car has wheels

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

attribute

A

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

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

is-a

A

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

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

has-a

A

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

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

classX(Y)

A

Make a class named X that is-a Y

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

class X(object): def __init__(self, J)

A

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

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

class X(object): def M(self, J)

A

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

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

foo = X()

A

Set foo to an instance of class X

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

foo.M(J)

A

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

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

foo.K = Q

A

From foo get the K attribute and set it to Q

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

class

A

Tell Python to make a new type of thing

17
Q

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

A

object

18
Q

What you get when you tell Python to create a class

A

instance

19
Q

How you define a function inside a class

A

def

20
Q

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

A

self

21
Q

The concept that one class can inherit traits from another class, much like you and your parents

A

inheritance

22
Q

The concept that a class can be composed of other classes as parts, much like how a car has wheels

A

composition

23
Q

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

A

attribute

24
Q

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

A

is-a

25
Q

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

A

has-a

26
Q

Make a class named X that is-a Y

A

classX(Y)

27
Q

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

A

class X(object): def __init__(self, J)

28
Q

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

A

class X(object): def M(self, J)

29
Q

Set foo to an instance of class X

A

foo = X()

30
Q

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

A

foo.M(J)

31
Q

From foo get the K attribute and set it to Q

A

foo.K = Q

32
Q

Tell Python to make a new type of thing

A

class