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