Level 1 : What will the following code produce?


from collections import Counter
data = [1, 2, 2, 3, 3, 3]
counter = Counter(data)
print(counter.most_common(2))

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