• 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))
  • 相关阅读:
    双飞翼布局 & 圣杯布局
    php正则
    面向对象-object对象
    面向对象-赋值运算
    面向对象-作用域
    js高级-面向对象
    8.5学习笔记
    10.22
    10.19
    react路由
  • 原文地址:https://www.cnblogs.com/ericblog1992/p/11269860.html
Copyright © 2020-2023  润新知