Level 5 : What will be the output of the following code snippet?


def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n - 1)

print(factorial(5))

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