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