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