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


def fibonacci(n):
    if n <= 1:
        return n
    else:
        return fibonacci(n-1) + fibonacci(n-2)

print(fibonacci(6))

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