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