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