Level 6 : What will be the output?


d = {1: 'A', 2: 'B'}
print(d.setdefault(3, 'C'))
print(d)

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