Level 9 : What will be the output of the following code snippet?


def solve(a, b):
   return b if a == 0 else solve(b % a, a)
print(solve(20, 50))

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