Level 5 : What will be the output of the following Python code ?


x = 2
for i in range(x):
    x -= 2
    print (x)

Author: SandhyaR | Tags: loop | 1736+ Python FAQs | Share
version-check | parameter | syntax-error | copy | classes | goto-function | call | data-structure | sys | method | debugging | lists | iterable | import-method | counter-function | logical-operation | type_conversion | asyncio-module | list-comprehension | version | identifier | built-in-function | assert | random | error | update | id-function | filter | input-function | precedence-and-associativity | string-iteration | arithmetic-operation | string-formatting | keyword | return-statement | data-structure | objects | math | pep | access-modifier | matrix-list-comprehension | exponentiation | format | file-handling | encapsulation | type-conversion | string-concatenation | loop-control | tuple | expression | split | bitwise-operator | global-variable | random-function | append | join | __future__ | comparison | global-keyword | loop | polymorphism | type-conversion | round-function | arithmetic-expression | heap-memory | collections | for | string-manipulation | memory-management | else-statement | dictionary | datetime | conversion | identity-operator | class-and-inheritance | turtle | docstring | comment | identity-operator | operator-or | memory | range | scientific-notation | deep-copy | variable | expand-tab | file_handling | formal-and-actual-parameter | operator | command-line-parsing | assignment-operator | decimal | dicts | fabs-function | python-django | floating-point-precision | collection | multiprocessing | sum-function | iterator | touples | filter-function | data_structure | list-method | typeerror | static-method | virtual-environment | immutable-data-type | list-join | generators | encoding | min-function | default-mutable-argument | odd-number | numeric | tuple-unpacking | namespace | lambda | data-structures | bitwise-operator | boolean | overflow | integer | constructor | escape-operator | center | feature | numpy | descriptors | factorial-function | python-repl | complex | function | input-function | class-and-instance-variable | magic-method | sorted | comprehension | while-and-for-loop | inherit | slicing | data-type | implementation | regex | destructor | namedtuple | data-type | string-formatting | boolean-and-non-boolean | postfix | matrix | name-mangling | control-flow | application | context-manager | inheritance | virtual-environment | indentation | sys-module | syntax-error | logical-operator | init | with-statement | complex-number | thread | mapping-function | string-method | list-mutation | file | conditional-statement | list-indexing | functions | pickling-&-unpickling | list-comprehension | list | mathematical-function | object-attribute | generators-in-python | operand | operator-overloading | bitwise | condition | asyncio | operations | immutability | function-argument | operator-and | multithreading | zip-function | while-else-loop | choice | design-principle | swapping | recurssion | package-management | file-handling | staticmethod | syntax | basic | indexing | print | statement | exception | pandas | binary-operation | oops | zfill-function | raise | mutable | yield | zip | lambdas | precedence | while-loop | string | stack | min-max-function | logical-operator | generator | dictionaries | list-slicing | error-handling | int | async | class-and-object | compute | sorting | string-slicing | class | math-copysign | exception-handling | exception-handling | print-statement | interpreter | list-operation | mysql | sum() | map-function | control-statement | recursion | control-flow | global | conditional-statement | built-in-function | regular-expression | shallow-copy | python-module | max-min | slice | methods | installation | lambda-function | higher-order-function | binary | oop | set | python-history | array | def | global-variable | input | round | multiple-inheritance | software-design | nested-loop | python_version | frozenset | head-and-tail | gil | match | functional-programming | matplotlib | pseudocode | string-slicing | attribute | set-operation | benefit | list-vs-tuple | enumerate() | string-method | operators | __all__-attribute | mathematics | loops | rollback | python | __init_subclass__ | module | counter | library | syntaxerror | invalid-list | function-and-scope | built-in | decorator | threading | datatype ...