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