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