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