Scroll Down to See All▾
absaiterallanextanyasciibinboolbreakpointbytearraybytescallablechrclassmethodcompilecomplexdelattrdictdivmodenumerateevalexecfilterfloatformatfrozensetgetattrglobalshasattrhashhelphexidinputintisinstanceissubclassiterlenlistlocalsmapmaxmemoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesortedstaticmethodstrsupertupletypevarszip__import__clear_(dict)clear_(list)clear_(set)copy_(dict)copy_(list)copy_(set)fromkeysgetitemskeyspop_(dict)pop_(list)pop_(set)popitemsetdefaultupdatevaluescount_(tuple)count_(list)count_(str)index_(tuple)index_(list)index_(str)adddifferencedifference_updatediscardintersectionintersection_updateisdisjointissubsetissupersetremove_(set)remove_(list)symmetric_differencesymmetric_difference_updateunionupdateclosefilenoflushisattyreadreadablereadlinereadlinesseekseekabletelltruncatewritablewritewritelinesappendextendinsertreversesortcapitalizecasefoldcenterencodeendswithexpandtabsfindformatisalnumisalphaisasciiisdecimalisdigitisidentifierislowerisnumericisprintableisspaceistitleisupperjoinljustlowerlstripmaketranspartitionreplacerfindrindexrjustrpartitionrsplitrstripsplitsplitlinesstartswithstripswapcasetitletranslateupperdirzfillFunction Details: sum
Description
Returns the sum of a 'start' value (default: 0) plus an iterable of numbers.
Extended Description
The sum() function adds the items of an iterable from left to right and returns the total. It starts with the optional 'start' value (which defaults to 0) and adds each item from the iterable to it. For numbers, it's equivalent to using the + operator in a loop. However, sum() is preferred for better performance and readability. Note that sum() is not recommended for concatenating strings; it's better to use ''.join(sequence) for that purpose.
Read More about sum from Python Documentation
Function Signature
sum(iterable: Iterable, start: Union[int, float] = 0) -> Union[int, float]
Module: builtins
Parameters
Parameter List
- iterable: Iterable
- start: Union[int, float]
Return
Returns the sum of all items in the iterable plus the start value.
Return Type
Union[int, float]
Output
Explanation
These examples show how sum() works with different types of iterables.