Level 10 : What will be printed?


class Counter:
    def __init__(self):
        self.value = 0
    def __call__(self):
        self.value += 1
        return self.value

c = Counter()
print(c(), c(), c())

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