Today I learn the loop in Python.It includes for sentence and while sentence.We should notice the law of them.
the loop in the Python(20170906)
example,for
sum = 0
for num in range(200):
sum = sum + num
print(‘the sum from 0 to 200 is:’,sum,len(range(200)))
example,while
sum2 = 0
num2 = 200
while num2 > 0:
sum2 = sum2 + num2
num2 = num2 - 2
print(‘the sum of even numbers in 0 to 200 is:’,sum2)
exersice
L = [‘Bart’, ‘Lisa’, ‘Adam’]
for L_show in L:
print(L_show)