Level 9 : What will be the output of the following Python program?


i = 0
while i < 5:
    print(i)
    i += 1
    if i == 3:
        break
else:
    print(0)

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