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