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