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