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