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 | 1736+ Python FAQs | Share
logical-operator | filter | list-comprehension | input | syntax-error | inheritance | higher-order-function | arithmetic-operation | default-mutable-argument | center | zip | global-variable | list-comprehension | python-history | async | generators | objects | version-check | sum() | zfill-function | comprehension | filter-function | for | file | precedence-and-associativity | dictionary | conversion | else-statement | collection | counter | thread | mysql | python-module | escape-operator | mathematical-function | rollback | frozenset | exception | pseudocode | multiple-inheritance | error | slicing | def | operator-overloading | __init_subclass__ | asyncio | map-function | sys | while-else-loop | operand | sum-function | bitwise-operator | generator | operators | list-mutation | feature | string-method | virtual-environment | benefit | string-slicing | string-concatenation | oop | syntaxerror | application | built-in-function | min-function | command-line-parsing | encoding | logical-operator | design-principle | lists | postfix | heap-memory | slice | module | boolean | integer | factorial-function | inherit | exception-handling | sorting | error-handling | built-in | bitwise | debugging | print | assignment-operator | function-argument | function-and-scope | __all__-attribute | control-statement | id-function | condition | overflow | comparison | set-operation | loops | datetime | attribute | fabs-function | indentation | scientific-notation | formal-and-actual-parameter | asyncio-module | docstring | matrix | raise | object-attribute | mutable | conditional-statement | operations | recurssion | installation | boolean-and-non-boolean | goto-function | exception-handling | statement | numeric | tuple | counter-function | lambda-function | assert | constructor | pandas | head-and-tail | gil | global-variable | operator-or | int | library | iterable | match | random-function | with-statement | turtle | python-django | memory-management | static-method | version | touples | syntax-error | precedence | classes | loop | identity-operator | max-min | threading | encapsulation | min-max-function | exponentiation | deep-copy | python | complex-number | list-vs-tuple | global-keyword | type_conversion | function | join | file-handling | namespace | type-conversion | data-type | package-management | format | file_handling | descriptors | oops | binary-operation | math | data-structure | input-function | string-method | copy | pep | data-structures | call | math-copysign | implementation | comment | matplotlib | methods | enumerate() | decimal | matrix-list-comprehension | string-iteration | destructor | round | data-structure | data_structure | context-manager | append | range | random | lambda | class-and-object | while-and-for-loop | name-mangling | polymorphism | class-and-instance-variable | method | choice | update | list | __future__ | mathematics | immutability | global | tuple-unpacking | string-formatting | while-loop | loop-control | list-indexing | numpy | stack | type-conversion | print-statement | binary | parameter | string-slicing | bitwise-operator | typeerror | decorator | set | staticmethod | identity-operator | sorted | import-method | dicts | nested-loop | class | string-manipulation | interpreter | floating-point-precision | identifier | complex | mapping-function | regex | odd-number | virtual-environment | file-handling | functions | collections | data-type | list-slicing | operator | round-function | access-modifier | shallow-copy | input-function | swapping | built-in-function | python_version | recursion | generators-in-python | arithmetic-expression | variable | expression | list-method | yield | sys-module | compute | immutable-data-type | list-join | logical-operation | iterator | software-design | basic | operator-and | syntax | pickling-&-unpickling | multithreading | keyword | string | dictionaries | split | expand-tab | indexing | lambdas | control-flow | string-formatting | array | list-operation | namedtuple | datatype | conditional-statement | python-repl | functional-programming | multiprocessing | control-flow | zip-function | return-statement | regular-expression | invalid-list | class-and-inheritance | memory | init | magic-method ...