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