Deck 10: Astronomy: Creating Classes, Writing Constructors, Accessors, Mutators and Special Methods

ملء الشاشة (f)
exit full mode
سؤال
Every Python object is an instance of a(n):

A) data model.
B) class.
C) method.
D) algorithm.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The details about what an object can do are called:

A) methods.
B) instance data.
C) models.
D) data types.
سؤال
Which of the following is one of Python's collection classes?

A) int
B) float
C) bool
D) str
سؤال
The ____ operator is used to invoke a method of an object.

A) dot
B) equals
C) dash
D) star
سؤال
Case Study 1:
>>> count = 1
>>> count = count + 1
>>> count
2
>>> count = count.__add__(1)
>>> count
3
>>>
>>> mylist.__getitem__(1)
66
-Refer to the session in the accompanying Case Study 1. What is the equivalent of the + operator?

A) __getItem__
B) __add__
C) ++
D) =
سؤال
Case Study 1:
>>> count = 1
>>> count = count + 1
>>> count
2
>>> count = count.__add__(1)
>>> count
3
>>>
>>> mylist.__getitem__(1)
66
-Refer to the session in the accompanying Case Study 1. What is the equivalent of the __getItem__ operator?

A) []
B) __add__
C) +
D) =
سؤال
What keyword defines a class in Python?

A) get
B) construct
C) def
D) class
سؤال
In Python, the constructor is always named:

A) __get__.
B) __init__.
C) constructor.
D) class.
سؤال
In a Python class, ____ refers to the object for which the method was called.

A) self
B) init
C) obj
D) class
سؤال
An accessor method is most likely to be used to implement:

A) mutator methods.
B) information hiding.
C) a constructor.
D) the dot operator.
سؤال
The print method invokes the ____ method of a class.

A) __print__
B) __str__
C) print
D) out
سؤال
____ objects store method names that refer to method definitions that are implemented by the class.

A) Mutator
B) Instance
C) Class definition
D) Self
سؤال
____ methods change an object in some way.

A) Accessor
B) Instance
C) Print
D) Mutator
سؤال
Preceding an instance variable name by two underscores____ the instance variable.

A) exposes
B) hides
C) mutates
D) accesses
سؤال
Case Study 2:
1. def createSSandAnimate():
2. ss = SolarSystem(2, 2)
3.
4. sun = Sun("SUN", 5000, 1000, 5800)
5. ss.addSun(sun)
6.
7. m = Planet("MERCURY", 19.5, 1000, .25, 0, 2, "blue")
8. ss.addPlanet(m)
9.
10. m = Planet("EARTH", 47.5, 5000, 0.3, 0, 2.0, "green")
11. ss.addPlanet(m)
12.
13. m = Planet("MARS", 50, 9000, 0.5, 0, 1.63, "red")
14. ss.addPlanet(m)
15.
16. m = Planet("JUPITER", 100, 49000, 0.7, 0, 1, "black")
17. ss.addPlanet(m)
18.
19. numTimePeriods = 2000
20. for aMove in range(numTimePeriods):
21. ss.movePlanets()
22.
23. ss.freeze()
24.
-Refer to the session in the accompanying Case Study 2. Which line(s) perform the actual work of the animation?

A) 4-5
B) 10-11
C) 16-17
D) 19-21
سؤال
Algorithms describe the solution to a problem in terms of the data needed to represent the problem instance and a set of steps necessary to produce the intended result.
سؤال
To create an instance of a class, call the __init__ method directly.
سؤال
Each object from a particular class has the same instance variables, but the values of those variables are different, therefore allowing the object to "behave" differently when asked to perform methods.
سؤال
The __class__ method is used to provide each object with a reference to the class definition object to which it belongs.
سؤال
The turtle module only allows one turtle to exist simultaneously in the same window.
سؤال
Match each definition with its term.
-Refers to the values of all instance variables for an object.

A) State
B) Class
C) Mutator method
D) Accessor method
سؤال
Match each definition with its term.
-Describes what an object will "look" like, what an object knows about itself, and what an object can do.

A) State
B) Class
C) Mutator method
D) Accessor method
سؤال
Match each definition with its term.
-Describes a procedure that changes an object in some way.

A) State
B) Class
C) Mutator method
D) Accessor method
سؤال
Match each definition with its term.
-Sometimes referred to as a "getter" method.

A) State
B) Class
C) Mutator method
D) Accessor method
سؤال
What does it mean to say that "Python supports the object-oriented programming paradigm?"
سؤال
What are some of the primitive and collection classes built into the Python language?
سؤال
What is a constructor method?
سؤال
What are accessor methods?
سؤال
What are mutator methods?
سؤال
Explain how method definitions are stored in Python.
سؤال
Explain the use of special class methods that Python provides.
سؤال
What is velocity? Provide an example to illustrate.
سؤال
Provide a high-level overview of the steps needed to create an animation of planets moving around the sun.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/33
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 10: Astronomy: Creating Classes, Writing Constructors, Accessors, Mutators and Special Methods
1
Every Python object is an instance of a(n):

A) data model.
B) class.
C) method.
D) algorithm.
B
2
The details about what an object can do are called:

A) methods.
B) instance data.
C) models.
D) data types.
A
3
Which of the following is one of Python's collection classes?

A) int
B) float
C) bool
D) str
D
4
The ____ operator is used to invoke a method of an object.

A) dot
B) equals
C) dash
D) star
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
5
Case Study 1:
>>> count = 1
>>> count = count + 1
>>> count
2
>>> count = count.__add__(1)
>>> count
3
>>>
>>> mylist.__getitem__(1)
66
-Refer to the session in the accompanying Case Study 1. What is the equivalent of the + operator?

A) __getItem__
B) __add__
C) ++
D) =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
6
Case Study 1:
>>> count = 1
>>> count = count + 1
>>> count
2
>>> count = count.__add__(1)
>>> count
3
>>>
>>> mylist.__getitem__(1)
66
-Refer to the session in the accompanying Case Study 1. What is the equivalent of the __getItem__ operator?

A) []
B) __add__
C) +
D) =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
7
What keyword defines a class in Python?

A) get
B) construct
C) def
D) class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
8
In Python, the constructor is always named:

A) __get__.
B) __init__.
C) constructor.
D) class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
9
In a Python class, ____ refers to the object for which the method was called.

A) self
B) init
C) obj
D) class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
10
An accessor method is most likely to be used to implement:

A) mutator methods.
B) information hiding.
C) a constructor.
D) the dot operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
11
The print method invokes the ____ method of a class.

A) __print__
B) __str__
C) print
D) out
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
12
____ objects store method names that refer to method definitions that are implemented by the class.

A) Mutator
B) Instance
C) Class definition
D) Self
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
13
____ methods change an object in some way.

A) Accessor
B) Instance
C) Print
D) Mutator
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
14
Preceding an instance variable name by two underscores____ the instance variable.

A) exposes
B) hides
C) mutates
D) accesses
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
15
Case Study 2:
1. def createSSandAnimate():
2. ss = SolarSystem(2, 2)
3.
4. sun = Sun("SUN", 5000, 1000, 5800)
5. ss.addSun(sun)
6.
7. m = Planet("MERCURY", 19.5, 1000, .25, 0, 2, "blue")
8. ss.addPlanet(m)
9.
10. m = Planet("EARTH", 47.5, 5000, 0.3, 0, 2.0, "green")
11. ss.addPlanet(m)
12.
13. m = Planet("MARS", 50, 9000, 0.5, 0, 1.63, "red")
14. ss.addPlanet(m)
15.
16. m = Planet("JUPITER", 100, 49000, 0.7, 0, 1, "black")
17. ss.addPlanet(m)
18.
19. numTimePeriods = 2000
20. for aMove in range(numTimePeriods):
21. ss.movePlanets()
22.
23. ss.freeze()
24.
-Refer to the session in the accompanying Case Study 2. Which line(s) perform the actual work of the animation?

A) 4-5
B) 10-11
C) 16-17
D) 19-21
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
16
Algorithms describe the solution to a problem in terms of the data needed to represent the problem instance and a set of steps necessary to produce the intended result.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
17
To create an instance of a class, call the __init__ method directly.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
18
Each object from a particular class has the same instance variables, but the values of those variables are different, therefore allowing the object to "behave" differently when asked to perform methods.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
19
The __class__ method is used to provide each object with a reference to the class definition object to which it belongs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
20
The turtle module only allows one turtle to exist simultaneously in the same window.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
21
Match each definition with its term.
-Refers to the values of all instance variables for an object.

A) State
B) Class
C) Mutator method
D) Accessor method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
22
Match each definition with its term.
-Describes what an object will "look" like, what an object knows about itself, and what an object can do.

A) State
B) Class
C) Mutator method
D) Accessor method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
23
Match each definition with its term.
-Describes a procedure that changes an object in some way.

A) State
B) Class
C) Mutator method
D) Accessor method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
24
Match each definition with its term.
-Sometimes referred to as a "getter" method.

A) State
B) Class
C) Mutator method
D) Accessor method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
25
What does it mean to say that "Python supports the object-oriented programming paradigm?"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
26
What are some of the primitive and collection classes built into the Python language?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
27
What is a constructor method?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
28
What are accessor methods?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
29
What are mutator methods?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
30
Explain how method definitions are stored in Python.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
31
Explain the use of special class methods that Python provides.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
32
What is velocity? Provide an example to illustrate.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
33
Provide a high-level overview of the steps needed to create an animation of planets moving around the sun.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.