zoukankan      html  css  js  c++  java
  • python04 while循环

     #下图为到三角:
    num=5 while num>0: tem=num while tem>0: #嵌套循环 print("#",end=" ") tem-=1 print() num-=1

    #a=1000
    b=a

    b=1000
    a=900

    九九乘法表:

    倒序:
    first=9 #second=9 while first>0: tem=1 while tem<=first: # print(tem,"*",first,"=",first*tem,end=" ") print(str(tem)+"*"+str(first)+"="+str(first*tem),end=" ") # 是制表符 是换行 print()默认换行 tem+=1 #print(first,"*",first,"=",first) print() first-=1 正序: first=1 #second=9 while first<=9: tem=1 while tem<=first: # print(tem,"*",first,"=",first*tem,end=" ") print(str(tem)+"*"+str(first)+"="+str(first*tem),end=" ") #第二行是数字强转字符串,通过+连接起来 tem+=1 #print(first,"*",first,"=",first) print() first+=1

    a>b  yi         #>因为旁边有两个数字,所以被称为二幕运算符或者二元运算符。

    not a>b    #not 因为右边只有一个整体,所以被称为一幕运算符或者一元运算符

    #and  not   or 运算符优先级用()来表示。

    while 条件1:

        ..........

        while 条件2:

         ..........

    break 中断某次循环

    continue 跳过当次循环

    #while 循环结构:

    while 判断条件:

      执行语句....

    else:

      执行语句...

    while循环else语句比较特殊,只有正常结束条件(非break)下才会执行。  

  • 相关阅读:
    New starting
    Ubuntu中PyCharm中字体设置
    pyshp操作shapefile
    GIS的数学基础
    向mysql中插入Date类型的数据
    mysql多字段排序
    干掉命令行窗口下MySql乱码
    JavaWeb中读取文件资源的路径问题
    Java中9种IO的读取方式
    JavaIO 将数据写入到文件中去
  • 原文地址:https://www.cnblogs.com/minkillmax/p/7868730.html
Copyright © 2011-2022 走看看