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