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

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Match each definition with its term. -Refers to the values of all instance variables for an object.

(Multiple Choice)
4.7/5
(34)

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?

(Multiple Choice)
4.9/5
(27)

Match each definition with its term. -Describes a procedure that changes an object in some way.

(Multiple Choice)
4.8/5
(40)

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.

(True/False)
4.8/5
(43)

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.

(True/False)
4.9/5
(34)

Preceding an instance variable name by two underscores____ the instance variable.

(Multiple Choice)
4.9/5
(37)

Which of the following is one of Python's collection classes?

(Multiple Choice)
4.8/5
(37)

The turtle module only allows one turtle to exist simultaneously in the same window.

(True/False)
4.8/5
(49)

The __class__ method is used to provide each object with a reference to the class definition object to which it belongs.

(True/False)
4.9/5
(41)

____ objects store method names that refer to method definitions that are implemented by the class.

(Multiple Choice)
4.9/5
(38)

In Python, the constructor is always named:

(Multiple Choice)
4.8/5
(27)

What are mutator methods?

(Essay)
4.7/5
(36)

Explain the use of special class methods that Python provides.

(Essay)
4.9/5
(37)
Showing 21 - 33 of 33
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)