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