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