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