Level 9 : What will the following code output?


class A:
    def __init__(self):
        self.data = "A"
    
    def display(self):
        print(self.data)

class B(A):
    def __init__(self):
        super().__init__()
        self.data = "B"

a = A()
b = B()
a.display()
b.display()

Author: VenuEmmela | Tags: init | 1859+ Python FAQs | Share
counter-function | generators | identifier | list-indexing | import-method | writing:-write(),-writelines() | booleans | joining-and-merging-dataframes | built-in-function | aggregating-data-with-functools.reduce() | exception-handling | introduction-to-multiprocessing | iterable | attribute | filter-function | immutability | input | input-function | basic | lambda-functions | identity-operators-(is,-is-not) | fabs-function | array | directory-operations | arithmetic-expression | escape-operator | installation | filtering-and-indexing | __all__-attribute | list-comprehension | goto-function | regular-expression | single-inheritance | assignment-operator | built-in-function | application | namespace | sys | append | managing-directories-with-os-and-shutil | bitwise | round | memory | name-mangling | syntax-error | sets | floats | operations | string-manipulation | list-operation | choice | binary | stack | heap-memory | list-method | set-operation | python-repl | creating-and-starting-threads | set | regular-expressions | walking-through-directories-using-os.walk() | mysql | integers | string-formatting | version | object-attribute | using-os-and-pathlib-modules | exception-handling | range | string-slicing | pass | operator-or | lambdas | reading-and-writing-large-files-efficiently | file | debugging | thread-synchronization | data-structures-in-python | list | operator-and | docstring | descriptors | functional-programming | loop-control-statements | error-handling | polymorphism | type-conversion | difference-between-threads-and-processes | round-function | unit-testing | __future__ | sorted | format | global-variable | test-discovery | advanced-file-operations | keyword | introduction-to-threads | else | global-variable | tuple-methods | exception | python-syntax-and-structure | feature | module | operators | creating-custom-modules | tuples | list-join | frozenset | oop | intering | higher-order-function | using-the-threading-module | floating-point-precision | indentation | complex | loop-control | pickling--unpickling | using-yield-in-functions | virtual-environment | mapping-function | data-types | matrix | counter | memory-management | dictionary-comprehensions | string-iteration | string-concatenation | function-argument | lambda | data_structure | dicts | parameter | expand-tab | complex-number | conditional-statements | default-mutable-argument | multiple-except-blocks | split | tuple | method | context-manager | design-principle | key-value-pairs | else-statement | recurssion | working-with-temporary-files-using-tempfile | touples | while-and-for-loop | while-else-loop | init | list-mutation | immutable-data-type | sum() | list-methods-and-slicing | thread-safe-data-structures-(queue.queue) | expression | comprehension | overflow | data-type-conversions | methods | staticmethod | working-with-dates-and-times | conditional-statement | file-handling | formal-and-actual-parameter | opening-files-(open()) | functions | constructor | syntaxerror | type_conversion | python-history | zip-function | loops | collection | dictionary-methods | while-loop | multiprocessing | logical-operators | pseudocode | access-modifier | random-function | assert | class-and-inheritance | sys-module | introduction-to-python | functional-programming | exponentiation | scientific-notation | for | precedence | zip | integer | implementation | indexing:-loc-vs-iloc | list-comprehension | logical-operation | python_version | type-conversion | deep-copy | iterators | list-vs-tuple | data-structure | quantifiers-(*,-+,-?,-{}) | string | collections | handling-missing-values-(fillna,-dropna) | dictionaries | __init_subclass__ | inheritance | tuple-unpacking | logical-operator | arbitrary-arguments-(*args,-**kwargs) | pandas | list-slicing | using-map()-for-transformations | multithreading | string-formatting | generator | bitwise-operator | math-copysign | namedtuple | benefit | conversion | def | using-lists-as-stacks | gil | condition | strings | swapping | error | list,-set,-and-dictionary-comprehensions | class | recursion | package-management | function | raise | filter | reading-and-writing-files | string-method | file_handling | classes | function-and-scope | library | built-in | reading:-read(),-readline(),-readlines() | sorting | yield | literal-characters-and-special-characters | destructor | logical-operator | enumerate() | data-structures | odd-number | input-function | print | call | why-use-multiprocessing-over-threading?-(gil) | membership-operators-(in,-not-in) | string-methods | boolean | iterator | lists | encapsulation | nested-loop | update | numeric | time-series-with-pandas | parsing-with-strptime | print-statement | match | oops | invalid-list | type-conversion-and-casting | id-function | thread | encoding | async | method-overloading | rollback | factorial-function | identity-operator | comment | join | control-statement | command-line-parsing | boolean-and-non-boolean | asyncio | syntax | class-and-object | python-module | shallow-copy | compute | inherit | min-max-function | software-design | using-join()-and-is_alive()-methods | datetime.date,-datetime.time,-datetime.datetime | static-method | regex | dataframe-and-series-objects | global-keyword | indexing | slicing | control-flow | class-decorators | pep | with-statement | typeerror | min-function | dictionary | overriding-methods | identity-operator | numpy | precedence-and-associativity | comparison | sum-function | working-with-file-paths | conditional-statement | mathematical-function | data-structure | string-slicing | copy | datetime | version-check | global | raise-statement | variable | working-with-binary-files-(rb,-wb) | using-assertions-(assertequal,-assertraises) | max-min | defining-functions | zfill-function | virtual-environment | random | control-flow | matplotlib | multiple-inheritance | loop | built-in-modules | math | objects | slice | string-method | data-type | interpreter | lambda-function | return-statement | assignment-operators | matrix-list-comprehension | decimal | boolean-masking | data-type | anchors-(^,-$) | syntax-error | operator | arithmetic-operation | magic-method | bitwise-operator | decorator | formatting-with-strftime | file-handling | multiple-inheritance | error-handling | default-arguments | class-and-instance-variable | asyncio-module | turtle | head-and-tail | binary-operation | postfix | center | datatype | statement | threading | python-operators | mutable | generators-in-python | list-comprehensions | python | map-function | int | mathematics | using-else-and-finally | sorting-and-ranking | operator-overloading | while-loops | python-django | operand ...