• 第三堂课学习


    Python学习笔记第三课
    #While循环
    num=1
    while num<10
    print(num)
    num+=1
    if num==9:
    break
    #// 输出1-8 1 2 3 4 5 6 7 8

    #猜年龄的改进2
    age = 50

    while ture:
    user_input_age = int(input("Age is:"))
    if user_input_age == age:
    print("Congratulation,you got it")
    break
    elif user_input_age > age:
    print("Sorry,it is bigger!Maybe,you can try it again ")
    else:
    print("Sorry,it is smaller!Maybe,you can try it again ")
    print("End")


    #break与continue
    continue 指终止本次循环,跳转出下一次循环
    break 指终止循环,跳出循环,执行循环之外的语句

    #continue实例

    num = 1
    while num <= 10
    num+=1
    if num == 3
    continue
    print(num)
    '''else:
    print("This is else statement")'''

    #结果: 2 4 5 6 7 8 9 10 11

    #end的作用:

    print("Hello World!")
    print("Hello World!")
    print("Hello World!")
    #结果:
    Hello World!
    Hello World!
    Hello World!

    print("Hello World!",end="__")
    print("Hello World!",end="__")
    print("Hello World!",end="__")
    #结果:
    Hello World!__Hello World!__Hello World!

    ####
    换行
    回车 指把当前光标移动到最前端(第一个位置)

    ###
    实例一:
    num1=0

    while num1<=5:
    print(num1,end="_")
    num2=0
    while num2<=7:
    print(num2,end="-")
    num2+=1
    num1+=1
    print(end=" ") # 等价于 print()

    #输出结果:
    0_0-1-2-3-4-5-6-7-
    1_0-1-2-3-4-5-6-7-
    2_0-1-2-3-4-5-6-7-
    3_0-1-2-3-4-5-6-7-
    4_0-1-2-3-4-5-6-7-
    5_0-1-2-3-4-5-6-7-

    #练习题(9*9乘法表)
    1*1=1
    1*2=2 2*2=4
    1*3=3 2*3=6 3*3=9
    ...

    ###
    height = int(input("Height"))
    width = int(input("Width"))
    num_height = 1
    while num_height <= height:
    num_width = 1
    while num_width <=
    print("#",end="")
    num_width += 1
    print()
    num_height += 1
    #输出结果
    Height:3
    Width:4
    ####
    ####
    ####

    '''
    num = 4
    while num>0
    print("#",end="")
    num _= 1
    '''
    """
    num = 4
    while num>0
    print("",end="")
    num = 4
    while num>0
    print("#",end="")
    num -= 1
    num-=1
    print()

    """

    '''
    num2 = 3 # 第一步 赋值
    while num2 > 0: # 第二步 判断
    num1 = 2 # 第三步 赋值
    while num1 > 0: # 第四步 判断
    print("#",end="") #// 不换行 ;打印#
    num1 -= 1 # num1减1
    print() # 只是换行
    num2 -= 1 # num2减1

    # 结果:
    ##
    ##
    ##
    '''

  • 相关阅读:
    Eclipse连接MySQL数据库(傻瓜篇)
    JMeter监控内存及CPU ——plugin插件监控被测系统资源方法
    fiddler抓取手机端的数据流量包
    python 字典(dictionary)一些方法
    python 循环语句
    Charles 抓 HTTPS 包
    python RSA 加密与签名
    从零开始做一个Jmeter性能测试
    [python之路]变量和字符编码
    [python之路]简单介绍
  • 原文地址:https://www.cnblogs.com/Skypeduty1225/p/8350624.html
Copyright © 2020-2023  润新知