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