for item in 'Python':print(item, end='')
print()for item in range(10):print(item, end='')# 当不需要自定义变量时候,可以用”_“代替
for _ in range(5) :print('hello world')# 计算累加和
sum = 0
for i in range(1,101) :if i%2==0 :sum +=i
print(sum)
While:
a = 0
while(a<10) :print(a)a+=2#计算100以内的奇数和
sum = 0
a = 0
while(a<=100) :if a%2!=0:sum += aa +=1
print(sum)