Level 9 : What will be the output of the following Python code?


i = 1
while True:
    if i%2 == 0:
        break
    print(i)
    i += 2

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