Level 9 : What is the output of the following code?


class Teacher:  
    def __init__(self, id, age):  
        self.id = id  
        self.age = age  
        print(self.age)  
tear = Teacher("John", 20)  
tear.age = 30  
print(tear.age)

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