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