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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 04:00
Acetylene is a gas which burns rapidly on its own, and is considered highly explosive. a) true b) false
Answers: 2
question
Computers and Technology, 24.06.2019 05:00
Who is most likely be your target audience if you create a slide presentation that had yellow background and purple text
Answers: 2
question
Computers and Technology, 24.06.2019 16:00
Which type of cloud computing offers easily accessible software and applications on the machines
Answers: 1
question
Computers and Technology, 24.06.2019 17:40
Anewly established internet company with 40 employees needs your advice. they are looking for a collaboration tool and have narrowed their choices to gotomeeting, webex, and my web conferences. after reading the information presented in this chapter and other sources, prepare a two- page document ( double spaced) that includes two advantages and two disadvantages of each tool. which one is your final recommendation? why did you choose that tool over the other two?
Answers: 3
You know the right answer?
Class Spell(object):
def __init__(self, incantation, name):
self. name = name
self...
Questions
question
Mathematics, 11.06.2021 03:50
question
Mathematics, 11.06.2021 03:50
question
Law, 11.06.2021 03:50
Questions on the website: 13722367