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