why 6 is displayed | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
23rd Jun 2021, 6:04 PM
Ulmas
3 Answers
+ 5
Hello Ulmas range(4) starts at 0 and ends at 3. 0 + 1 + 2 + 3 = 6 In general: range(a,b,c) a = start (default = 0) b = end (exclusive) c = step (default = 1)
23rd Jun 2021, 6:11 PM
Denise Roßberg
Denise Roßberg - avatar
0
#see output:Ulmas it explains : def print_num(x): res=0 print("res+i") for i in range(x): #res+=i print(res,'+',i,'=>',"res=" ,res:=res+i) return res print (print_num (4))
23rd Jun 2021, 6:13 PM
Jayakrishna 🇮🇳
0
Ulmas I<4. This is followed I<=4 is not followed
23rd Jun 2021, 6:14 PM
Atul [Inactive]