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