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