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