It didn’t give me right answers


#1

hi guys!!

I tried solve the problem with the coding below. However, it didn’t give me right answers. I got (2 4 and 25) as answer.

Can you guys explain me why do i need to set : print num**2, instead of what i did.
thanks

num = 1

while num <=10: 
    num = num**2
    print num
    num += 1

3.While you're at it Answer
#2

you use num in the whole loop condition, so num should increase by one every iteration of the loop, which you do:

num += 1

but you also store num ** 2 in num, causing num to increase way to rapid

store num ** 2 in a different variable so num doesn’t increase to quickly


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.