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