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