Whats going on here? Help me please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats going on here? Help me please

i = 1 while i <= 10: print (i ** 2 ) i += 1

20th Jun 2020, 6:13 AM
Umar
Umar - avatar
4 Answers
+ 6
Efe (**) this sign means power 1)i=1 ==>i**2=1**2=1 2)i=1 ==>2**2=2**2=4 3)i=3 ==>3**2=3**2=9 4)i=4 ==>4**2=4**2=16 5)i=5 ==>5**2=5**2=25 6)i=6 ==>6**2=6**2=36 7)i=7 ==>7**2=7**2=49 8)i=8 ==>8**2=8**2=64 9)i=9 ==>9**2=8**2=81 10)i=1 ==>10**2=10**2=100
20th Jun 2020, 6:54 AM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 3
Step1(i=1): checks i<=10 ..true Print i^2 ..i.e. 1 (Above line just prints, i is still "1") i+=1 ..now i=2 Step2(i=2): checks i<=10 ..true Print i^2 ..i.e. 4 (Above line just prints 4, i is still 2) i+=1 ..now i=3 Step3(i=3): checks i<=10 ..true Print i^2 ..i.e. 9 (Above line just prints 9, i is still 3) i+=1 ..now i=4 Step4(i=4): And so on..
20th Jun 2020, 7:23 AM
Blue!!
Blue!! - avatar
0
I know the answer but could not understand how it works
20th Jun 2020, 6:27 AM
Umar
Umar - avatar
0
Blue!! Thank you bro
20th Jun 2020, 5:09 PM
Umar
Umar - avatar