Level 10 : What will the following code output?


def union_of_sets(s, t):
    s |= t
    s.discard(5)
    return s, len(s)

s = {1, 2, 3, 4, 5}
t = {4, 5, 6, 7}
result = union_of_sets(s, t)

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