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