Level 9 : What is the output for below code?


x = (i**2 for i in range(3))
print(sum(x))
print(sum(x))

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