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