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