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