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