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