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