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