subject

Class Spell(object):
def __init__(self, incantation, name):
self. name = name
self. incantation = incantation

def __str__(self):
return self. name + ' ' + self. incantation + '\n' + self. getDescription()

def getDescription(self):
return 'No description'

def execute(self):
print self. incantation

class Accio(Spell):
def __init__(self):
Spell.__init__(self, 'Accio', 'Summoning Charm')

class Confundo(Spell):
def __init__(self):
Spell.__init__(self, 'Confundo', 'Confundus Charm')

def getDescription(self)
return 'Causes the victim to become confused and befuddled.'

def studySpell(spell):
print spell

spell = Accio()
spell. execute()
studySpell(spell)
studySpell(Confundo())
Based on the Python code given above, answer the following questions:

a) Which are the parent and child classes here?

b) What is the output of the code? (Try figuring it out without running it)

c) Which get_description() method is called when the ‘study spell(Confundo())’ function

is executed? Why?

d) What do we need to do so that that statement print(Accio()) will print the

description ‘This charm summons an object to the caster, potentially over a significant distance’? Write down the code that needs to be added or changed.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:10, reycaden
David is in week 3 of his current ashford course and has a paper due by monday night at midnight. he has finished everything but the concluding paragraph. as he boots up his computer to work on it, he sees a flash across the screen and then the screen goes black. he begins to panic as he tries desperately to turn the laptop back on. david should have saved his work on what kind of portable device?
Answers: 2
image
Computers and Technology, 23.06.2019 17:20, Morehollie9428
What is the best assassins creed game?
Answers: 2
image
Computers and Technology, 23.06.2019 18:30, janny48
How often does colleges update the cost of attendance on their website? . a)every two years b) every four years c) every year d) every semester
Answers: 1
image
Computers and Technology, 24.06.2019 16:00, alexisbeasley2
Which of the following characters is acceptable to use in a filename? ? / – %
Answers: 1
You know the right answer?
Class Spell(object):
def __init__(self, incantation, name):
self. name = name
self...

Questions in other subjects:

Konu
Biology, 07.10.2019 21:00