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, 21.06.2019 19:30
Can you make money in why are you guys so
Answers: 1
question
Computers and Technology, 22.06.2019 09:50
17. implement the jvm dload instruction for the mic-2. it has a 1-byte index and pushes the local variable at this position onto the stack. then it pushes the next higher word onto the stack as well
Answers: 2
question
Computers and Technology, 22.06.2019 19:30
Once the data center routes to the destination server that hosts the website, what's the next step in the internet process? user’s browser renders html code from destination server into web page request goes through router/model and isp request routed to nameserver and datacenter
Answers: 2
question
Computers and Technology, 23.06.2019 18:30
Report all segments of identity by descent longer than 20 polymorphisms between pairs of individuals in the following cohort of 15 individuals across 49 polymorphisms: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 numeric input 2 points possible (graded) you have 2 attempts to complete the assignment below. for example if the sequence is "bcd", which occurs in "abcdef" , the starting point would be 2 (b), and the finishing point would be 4(d). individuals 7,10 between positions
Answers: 1
You know the right answer?
Class Spell(object):
def __init__(self, incantation, name):
self. name = name
self...
Questions
question
English, 22.09.2019 02:00
Questions on the website: 13722367