Recap - Sigma Function
Part of the Fundamentals section of Coddy's Python journey — lesson 46 of 77.
Challenge
EasyWrite a function named sigma with one argument that represents a number n.
The function will return the sum of all the numbers from 1 to n (including).
For example, for sigma(5), the function will return 15, because 15 = 1 + 2 + 3 + 4 + 5.
Important! You don't need to call the function we do that for you behind the scenes in a function type challenges.
Note: The result must be an integer — the sum of whole numbers is always a whole number.
Try it yourself
def sigma(n):All lessons in Fundamentals
4Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Logical Operators Part 48Loops
For LoopWhile LoopBreakContinueRecap - FactorialThe Range FunctionNested LoopRecap - Dynamic Input3Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators9Functions
Declare a FunctionArgumentsReturnRecap - Sigma FunctionRecap - Validation FunctionDefault Values12Iterating Over Sequences
Iterating Over ElementsThe Enumerate FunctionIterating Over Strings Part 1Iterating Over Strings Part 2