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