← Back to challenges

Summation of the First n Terms

PythonHardmathloops

Instructions

Create a function that takes an expression exp and an upper limit i as arguments and returns the sum of that expression up to the i'th term (recall sigma from math class).

Examples

summation("n", 10) ➞ 55

summation("1/n", 50) ➞ 4.5

summation("n**n", 6) ➞ 50069

Notes

  • Assume the lower limit is i = 1.
  • Round your answer to the nearest tenth.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.