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