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