python while循环

#  循环语句
# while 循环

'''
i = 0;
while i < 5:
print('python is the best language')
i += 1
# 阶乘计算器

i = 1
result = 1
while i <= 2:
result = result * i
if i % 5 == 0:
print("{}:{}".format(i, result))
i += 1
print(result)

#continue 跳过当前循环
start = 101
end = 183
i = 100
while i <= 182:
i += 1
if i % 17 != 0:
continue
print(i)

#continue 终止循环
start = 100
end = 150
i = 100
while i <= 200:
i += 1
if i >150:
break
print(i)

'''

# j = 0
# while j < 6 :
# i = 0
# while i < 6:
# print('口', end = "") #结尾不换行
# i += 1
# j += 1
# print("")
# 口口口口口口
# 口口口口口口
# 口口口口口口
# 口口口口口口
# 口口口口口口
# 口口口口口口

# 查找1000以内的质数
num = 17
i = 2
is_prime = True
while i < num:
if num % i == 0:
break
i += 1
if is_prime == False:
print("{}不是质数".format(num))
else:
print("{}是质数".format(num))
posted @ 2019-07-30 14:33  EricBlog  阅读(193)  评论(0编辑  收藏  举报