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