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