Level 1 : What will be the output of the following code snippet?


a = [1, 2, 3, 4, 5]
sum = 0
for ele in a:
   sum += ele 
print(sum)

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