Super Violin

Report a typo

Below you can see a hierarchy of classes.

class Instrument:
    def __init__(self, size):
        self.size = size

class Stringed(Instrument):
    def __init__(self, n_strings):
        self.n_strings = n_strings

class Violin(Stringed):
    def __init__(self, cost):
        super().__init__(4)
        # ???
        self.cost = cost

my_violin = Violin(680)
print("size:", my_violin.size, 
      "\nstrings:", my_violin.n_strings, 
      "\ncost:", my_violin.cost)

Select what we should write instead of the question marks in the Violin's __init__ so that the output will be as follows:

size: 50 
strings: 4 
cost: 680

Remember that super().__init__(name) is the same as super(Child, self).__init__(name).

Select one option from the list
___

Create a free account to access the full topic