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