Level 8 : 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 | 1736+ Python FAQs | Share
string | data_structure | library | command-line-parsing | import-method | return-statement | pickling-&-unpickling | polymorphism | sys | version | memory-management | exception-handling | fabs-function | lambda | string-formatting | async | string-manipulation | class-and-inheritance | python-django | append | bitwise-operator | decimal | string-concatenation | binary-operation | software-design | floating-point-precision | arithmetic-operation | debugging | precedence-and-associativity | exponentiation | scientific-notation | split | classes | overflow | filter-function | list-comprehension | memory | deep-copy | while-else-loop | class | name-mangling | conditional-statement | collections | string-slicing | odd-number | lambda-function | string-iteration | shallow-copy | dictionary | generator | counter | stack | file | interpreter | zip-function | yield | docstring | destructor | random | python-module | virtual-environment | condition | benefit | mapping-function | max-min | frozenset | oop | assert | recurssion | compute | bitwise | built-in | threading | list-comprehension | regular-expression | list-mutation | comprehension | objects | formal-and-actual-parameter | pandas | comment | error-handling | operand | operator | installation | rollback | datetime | choice | input-function | conditional-statement | factorial-function | slice | typeerror | encoding | array | attribute | functional-programming | expand-tab | copy | function-and-scope | file_handling | mathematical-function | head-and-tail | turtle | sum-function | method | functions | thread | else-statement | asyncio-module | conversion | collection | lambdas | operator-and | keyword | data-type | boolean | built-in-function | sorted | sys-module | descriptors | slicing | file-handling | exception | numeric | __init_subclass__ | list-method | global-variable | lists | asyncio | python_version | regex | round | __future__ | counter-function | integer | while-loop | dicts | string-method | loop | loop-control | exception-handling | center | mutable | print | version-check | bitwise-operator | feature | format | touples | type_conversion | global-keyword | staticmethod | object-attribute | __all__-attribute | min-function | def | encapsulation | recursion | id-function | heap-memory | comparison | python-repl | application | immutability | tuple | call | default-mutable-argument | for | tuple-unpacking | numpy | pep | oops | while-and-for-loop | data-type | operator-overloading | immutable-data-type | inheritance | identity-operator | python-history | indentation | with-statement | multithreading | built-in-function | math | random-function | basic | package-management | list | update | access-modifier | filter | class-and-instance-variable | goto-function | error | function | identifier | sum() | syntaxerror | identity-operator | match | postfix | print-statement | syntax-error | operators | round-function | context-manager | matrix-list-comprehension | implementation | expression | gil | list-vs-tuple | syntax | control-statement | python | class-and-object | global-variable | indexing | module | list-operation | nested-loop | iterable | data-structure | operator-or | set | complex-number | control-flow | syntax-error | list-indexing | higher-order-function | boolean-and-non-boolean | raise | static-method | statement | logical-operator | iterator | assignment-operator | join | range | parameter | loops | mathematics | invalid-list | variable | multiple-inheritance | escape-operator | methods | set-operation | swapping | arithmetic-expression | datatype | logical-operator | list-join | string-method | input | magic-method | generators | multiprocessing | precedence | int | map-function | namedtuple | init | zfill-function | namespace | data-structures | matplotlib | dictionaries | inherit | complex | operations | function-argument | constructor | decorator | generators-in-python | mysql | virtual-environment | input-function | string-formatting | sorting | design-principle | enumerate() | global | string-slicing | min-max-function | binary | logical-operation | type-conversion | type-conversion | control-flow | file-handling | matrix | list-slicing | data-structure | pseudocode | zip | math-copysign ...