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