for 循环:
涉及其它知识点:range,break,continue,pass
# range(stop) for i in range(5): print(i) # 输出0到4 # range(start,end,step) # start: 计数的起始值,默认0 # end:指定计数的结束值,但不包括该值 # step:指定步长 for i in range(1, 6, 1): print(i, end=' ') # 输出1到5 # end=' '输出时以空格分割,默认' '换行 print("今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问几何?") for i in range(100): if i % 3 == 2 and i % 5 == 3 and i % 7 == 2: print("答曰:此数为:", i) # 23 break # 符合要求直接退出for循环 # continue是跳过当前循环的剩余语句 # else: # pass # 占位符,不做任何事情