Clamps num
within the inclusive range specified by the boundary values.
num
falls within the range (a
, b
), return num
.def clamp_number(num, a, b):
return max(min(num, max(a, b)), min(a, b))
clamp_number(2, 3, 5) # 3
clamp_number(1, -1, -5) # -1
Python, Math
Initializes a list containing the numbers in the specified range where start
and end
are inclusive and the ratio between two terms is step
.
Python, Math
Checks if the given number falls within the given range.
Python, Math
Returns the sum of the powers of all the numbers from start
to end
(both inclusive).