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