Level 9 : What is the output of the following code?


def func(nums):
    return (n * n for n in nums if n % 2 == 0)

nums = [1, 2, 3, 4, 5]
gen = func(nums)
print(list(gen))

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