Level 5 : What is the output?


def squared_gen(limit):
    for i in range(limit):
        yield i ** 2

g = squared_gen(4)
print(sum(g))
print(sum(g))

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