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