Level 1 : What is the output?


def even_numbers(limit):
    for i in range(limit):
        if i % 2 == 0:
            yield i

g = even_numbers(6)
print(next(g))
print(next(g))
print(next(g))
print(next(g))

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