python unit 3 for loops and while loops

#for loops

sum=0

for i  in range(10)  :

    sum=sum+i

    print(sum)


# while loops is equal to for loops

sum=0

i=o

while i<10:

sum=sum+i

print(sum)

i=i+1

你可能感兴趣的:(python unit 3 for loops and while loops)