Level 5 : What will be the output of the following code snippet?


def countdown(n):
    if n <= 0:
        print("Done!")
    else:
        print(n)
        countdown(n - 1)

countdown(3)

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