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