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