输出1-10之间的数
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import time
n1 = 1
while True:
print(‘n1‘)
if n1 ==10:
break
n1 += 1
time.sleep(1)
print(‘end‘)
输出1-10之间除了7之外的数
start = 1
while True:
if start == 7:
start += 1
continue
print(‘start‘)
if start == 10:
break
start += 1
print(‘end‘)
输出1-100的和
sum = 0
start = 1
while True:
sum = sum + start
if start ==100:
break
start += 1
print(‘sum‘)
输出1-100之间的偶数
#-*- coding:utf-8 -*-
n1 = 1
while True:
if n1 %2 ==0:
print(‘n1‘)
if n1 == 100:
break
n1 += 1
print(‘end‘)
时间: 2024-10-29 19:13:27