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