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