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