Level 1 : What will be the output of the following Python code snippet?


test = {1:'A', 2:'B', 3:'C'}
del test[1]
test[1] = 'D'
del test[2]
print(len(test))

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