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