Level 9 : How can we swap two numbers in python without using the third variable?


x = 10
y = 20

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