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