zoukankan      html  css  js  c++  java
  • 循环

    • while  break:
    count = 0
    while True:
        count +=1#count = count + 1
        print(count)
        if count == 100:
            break
    • while 条件
    while count < 3 :   #注意这里需要:
    
        guest_age = int(input("guess age:"))
        if guest_age == age_of_oldboy :
            print("yes! you got it")
            break   #跳出循环
        elif guest_age > age_of_oldboy :
            print("you guess too bigger")
        else:
            print("you guess too small")
        count +=1 #count = count + 1
    • while  else

    格式:

    while 条件:
    print()
    else:
    print()
    while count < 3 :   #注意这里需要:
    
        guest_age = int(input("guess age:"))
        if guest_age == age_of_oldboy :
            print("yes! you got it")
            break   #跳出循环
        elif guest_age > age_of_oldboy :
            print("you guess too bigger")
        else:
            print("you guess too small")
        count +=1 #count = count + 1
    else:
        print("you guess too much !Fuck !")
    •  for循环
    for i in range(10):#相当于for i in range(0,10.1),意思是从0开始,数10个,间隔为1
        print(i)
    for i in range(0,10,2):#10为i从0开始数10次,2为间隔多少打印,这里为间隔2
        print(i)
    • for else
    for i in range(3):
    
        guess_age = int(input("guess age:"))
        if guess_age == age_of_oldboy:
            print("yes! you got it")
            break
        elif guess_age > age_of_oldboy:
            print("think small..")
        else:
            print("think bigger")
    
    else:
        print("fock you")
    • break  跳出当前循环,结束这个循环
    for i in range(10):
        print("----------------",i)
        for j in range(10):
            if j >4:
                break
            print(j)
    • continue:跳出本次继续,继续下一次循环
    for i in range(10):
        if i<3:
            print("loop:",i)
        else:
            continue
        print("hahahha")
    •  好
  • 相关阅读:
    poj 1113 Wall 凸包的应用
    NYOJ 78 圈水池 (入门级凸包)
    Monotone Chain Convex Hull(单调链凸包)
    poj Sudoku(数独) DFS
    poj 3009 Curling 2.0(dfs)
    poj 3083 Children of the Candy Corn
    Python join()方法
    通过FISH和下一代测序检测肺腺癌ALK基因融合比较
    华大病原微生物检测
    NGS检测ALK融合大起底--转载
  • 原文地址:https://www.cnblogs.com/cheng662540/p/8007137.html
Copyright © 2011-2022 走看看