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