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