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