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