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