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