Level 1 : what is the output of the following code?


i = 0
while i < 5:
    print(i)
    i += 1
    if i == 3:
        break
else:
    print(0)

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