Closed lassearpe closed 3 years ago
Hi Lasse
Here, you want to write a function on the following form:
def my_fun(x, k_max):
my_sum = 0
for k in range(k_max + 1):
my_partial_sum = (k+x)**2
my_sum = my_sum + my_partial_sum
return my_sum
What I have used here is neither the right function nor the most elegant solution to the problem. However, it hopefully helps you understand how to (i) create a sum of a complicated expression (here a sum of (k+x)**2 with k going from 0 to k_max and x being some input of your choice), and (ii) create a sum-"loop".
Was this helpful?
Best, Joachim
Hi Joachim
Yeah, thanks a lot. I still find the mathmatics part a bit difficult to understand, but I will try to solve the problem to the best of my ability.
Best, Lasse
Hello everyone,
I am totally at odds trying to figure out problem 0.3.4.
I have two issues.
(And how does this bring a "partial" sum to add to the total value in each step of the loop?)
Any help appreciated, Lasse