• 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))
  • 相关阅读:
    JavaScript之Math和date
    JavaScript之ES5和String
    JavaScript之数组
    JavaScript之 函数
    JavaScript之循环语句
    movies.js
    Js内存存放机制
    Web框架
    css中那些属性是可以继承的?
    赋值运算
  • 原文地址:https://www.cnblogs.com/ericblog1992/p/11269860.html
Copyright © 2020-2023  润新知