• day 5


    默写

    # 1 栈区(对应关系) 变量名与变量值的内存地址()的映射关系  堆区 '值'(存在与变量名相对应的内存地址)
    # 直接引用 x = 10 y = x   变量名直接指向变量值的内存地址(从栈区出发与变量值直接引用)
    # 间接引用 l = [1,2,3,x]  变量名指向容器类型地址,容器内的元素指向变量地址(从栈区去出发
    name = input('>>>')
    age= input('...')
    gender = input(',,,')
    print('''
    我的是{}
    我的名字{}
    我的性别{}
    '''.format(name,age,gender))
    # 运算符
    # 赋值运算符
    # 变量运算符 =
    name = '阿里云'
    # 增量运算
    #  += -= *= /= //= **=
    # 交叉赋值
    # x , y =y ,x
    # x = y = 10
    # 解压赋值
    #   x,y,z = [1,2,3,]
    
    # 计算运算符
    # + - * / // % * **
    View Code

    笔记

    # 可变不可变类型
    # 可变类型:改变变量  值改变'id'不变 改变的是原值 == 可变
    # 不可变数据类型:改变变量  值改变 id也变 改变的是地址 == 不可变
    #  ps 所有的 '=' 都是赋值,都会改变变量的地址
    # 字符串 整数 浮点数 bool 除了 赋值没有其他改变的方法  (都是不可变类型)
    # 列表
    l = [1, 2, 3, ]
    print(id(l), l)
    l[1] = '233'
    print(id(l), l)
    # 可变
    # 字典
    l = [1, 2, 3, ]
    print(id(l), l)
    l[1] = '233'
    print(id(l), l)
    # 逻辑运算符
    print(True and 10)
    print(2 > 1 and 1 != 1 and True and 3 > 2)
    print(2.1 or 1 != 1 or True or 3 > 2)
    # not
    # (假为真,真为假)
    # and
    # (全真威震,一假为假)
    # or
    # (一真为真,全假为假)
    
    # 优先级
    # not优先级最高
    # and
    # or
    # 短路运算
    # 逻辑运算符的结果一旦可以确定 那么就以当前计算到的值作为最终结果返回
    print(10 and 0 or '' and 0 or 'abc' or 'egon' == 'dsb' and 333 or 10 > 4 )
    # 成员运算符 in  not in
    # var = print('egon' not in 'my name is egon') == print(not 'engon' in [True])
    #  一样
    # ps : in 优先级在not之前  建议用第一种
    # 身份运算符 is (is not)
    # 比较id id相同则返回True
    #           不同则返回False
    
    # 条件判断
    # score = int(input('请输入你考的分数'))
    # # if score >= 580:
    # #     print('985')
    # # else:
    # #     print('普通大学')
    # if 100>=score>90:
    #     print('A')
    # elif 90>=score>80:
    #     print('B')
    # elif 80>=score>70:
    #     print('c')
    # elif 70 >= score>60:
    #     print('D')
    # elif 60>= score:
    #     print('E').
    import random
    n = random.randint(0,100)
    while 1:
        user_gusee = int(input('place guess this number'))
        if user_gusee == n:
            print('GOOD ! true')
            break
        elif user_gusee < n:
            print('smaller')
        elif user_gusee > n:
            print('digger')
    View Code

    作业

    # while 循环嵌套 + tag的使用
    # 针对嵌套多层的while循环,如果我们的密度很明确就是要在某一层次上退出所有层的循环其实有一个窍门就是让所有的while循环的条件
    # 都用同一个变量,该变量的初始值为True,一旦在某一层次将该变量的值False,则所有层的循环都结束.
    user_name = 'lee'
    passwod = '123'
    count = 0
    tag = True
    while tag :
        inp_name = input('请输入')
        inp_pwd = input('password')
        if inp_name == user_name and inp_pwd == passwod:
            print('登录成功')
            while tag:
                cmb = input('>>:')
                if cmb == 'quit':
                    tag = False
                    break # ( break只能跳出一层循环)
                print('run<%s>'% cmb)
            break  #有什么用
        else:
            print('登录失败')
            count +=1
            print(count)
    View Code
  • 相关阅读:
    Ant 中作用代理
    linux通用自动清理日志脚本
    linux shell 脚本攻略 下
    我在写shell自动部署脚本碰到的问题
    linux shell 脚本攻略(上)
    Java Object.wait() jvm的bug
    shell 脚本 更新或者添加host ,并且增加hostname映射到hosts (修改)
    记一次子域名IP搜集reconngkali
    ie6下面试用png使用滤镜需知
    canvas 使用 图片 切片的时候 在chrome 下 要注意的 一点
  • 原文地址:https://www.cnblogs.com/lee1225/p/12431671.html
Copyright © 2020-2023  润新知