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