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