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 05:00
Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. after the loop terminates, it prints out, on a line by itself and separated by spaces, the sum of all the even integers read, the sum of all the odd integers read, a count of the number of even integers read, and a count of the number of odd integers read, all separated by at least one space. declare any variables that are needed. assume the availability of a variable, stdin, that references a scanner object associated with standard input. that is, stdin = new scanner(system.in); is given.
Answers: 3
question
Computers and Technology, 23.06.2019 06:10
The head restraint should be adjusted so that it reaches a.the top of your ears b.the base of your skull c.the top of the head
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
Which analyst position analyzes information using mathematical models to business managers make decisions?
Answers: 1
question
Computers and Technology, 24.06.2019 21:50
The use of phrases, fragments, and punctuation can influence the mood of a passage; keeping this in mind, how would you describe the mood of the followingpassage? "fog on the essex marshes, fog on the kentish heights, fog creeping into the cabooses of collier-brigs; fog lying out on the yards, and hovering in the riggingof great ships; fog drooping on the gunwales of barges and small boats. fog in the eyes and throats of ancient greenwich pensioners, wheezing by thefiresides of their wards; fog in the stem and bowl of the afternoon pipe of the wrathful skipper; fog cruelly pinching the toes and fingers of his shivering little'prentice boy on deck." (5 points)
Answers: 2
You know the right answer?
Class Spell(object):
def __init__(self, incantation, name):
self. name = name
self...
Questions
question
Mathematics, 12.02.2020 17:46
question
Mathematics, 12.02.2020 17:46
question
Chemistry, 12.02.2020 17:46
question
Mathematics, 12.02.2020 17:46
question
Mathematics, 12.02.2020 17:46