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


x = (i for i in range(3))
for i in x:
    print(i)

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