+ 2
Help me to arrange this code
Hi guys help me to arrange this code res = 0 return res for i in range(x): def sum(x): res += i
6 Respostas
+ 2
Dion shaddy
I am not understanding what u talking about.
Please explain what u trying to say .
+ 1
What is your try? Pls mention your trouble in getting it right?
+ 1
Jayakrishna
It's model 6 Guiz ( arrange )
I try different way but I didn't get right arrangement
+ 1
Actually this is one of the quizzes where we drag those draggable lines and arrange them to make a meaningfully code segment right? Don't just try different combinations, find the correct answer and try that. The correct answer to this question is:
def sum(x):
res=0
for i in range(x):
res+=i
return res
First, a variable "res" is created to hold the sum of the numbers, with initial value 0. Then a loop runs from 0 to x and adds it to the variable "res". Finally "res" is returned. As simple as it sounds
+ 1
Rishi
tank you it is worked
+ 1
Dion Shaddy what are you trying to say? 😗