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