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