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