Level 1 : What will be the output of the following code?


a=0
while a<6:
    print(a)
    if a==4:
       break
else:
  print(0)

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