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