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