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