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