This seems like an easy one. My doubt is, when is "num" changing its value.
def nearest_square(limit):
num = 0
while (num+1)**2 < limit:
print(num)
num += 1
print(num)
retu num**2
limit = 20
print(nearest_square(limit))
OUTPUT:
0
1
2
3
16
In the code I am incrementing "num" twice. (Once in the condition of while loop and second inside the while loop)
برچسب:
نویسنده: آیلین رضوانی
تاريخ: سه
شنبه
5 دی
1396 ساعت: 14:37