Level 1 : What will be printed by this code?


d = {'x': 10}
d['y'] = d.get('y', []) + [20]
print(d)

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