0
What's the method for figuring out question 2 on module 3
I'm genuinely stuck with no clue of how to do this question. I have a feeling there's a bug in this question cause I've tried a lot of combination of answer and none have worked. If someone could at least give me a hint for this It would be appreciated. P.S. I have no more xp to get a hint since I wasted it not knowing how valuable it was. The question is: Rearrange the code to define a function that calculates the sum of all numbers from 0 to its argument The available lines to move around are: res=0 return res for i in range(x): res+=I def sum(x)
12 Answers
+ 5
This is ans :
def sum(x):
res = 0
for i in range(x):
res += i
return res
+ 3
The question is:
Rearrange the code to define a function that calculates the sum of all numbers from 0 to its argument
The available lines to move around are: res=0
return res
for i in range(x):
res+=I
def sum(x)
+ 2
Thank You for the answer. I've now finished the question
0
could you please post the full question to get a hint...
0
You can solve this by defining the function, setting res = 0 and then looping from 0 to x while adding loop counter every time in the res variable
0
i want the exact answer for this question
0
Tell me frnds that exact answer when you know about it
0
Answer:
def sum(x):
res = 0
for i in range(x):
res += i
return res
0
Thanks
0
Answer:
def sum(x):
res = 0
for i in range(x):
res += i
return res
- 1
no seeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- 1
Ha@aaaaaaaaaa