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