Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class Spell: def __init__(self, name, incantation): self.name = name self.incantation = incantation def __str__(self): return self.name + + self.incantation + +

class Spell: def __init__(self, name, incantation): self.name = name self.incantation = incantation def __str__(self): return self.name + " " + self.incantation + " " + self.get_description() def get_description(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 get_description(self): return "Causes the victim to become confused and befuddled" def study_spell(spell): print(spell) # test spell = Accio() spell.execute() study_spell(spell) study_spell(Confundo())

Based on the Python code given above, answer the following questions:

  1. a) Which are the parent and child classes here?

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

  3. c) Which get_description() method is called when the study spell(Confundo()) function

    is executed? Why?

  4. 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is the orientation toward time?

Answered: 1 week ago

Question

4. How is culture a contested site?

Answered: 1 week ago