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