zoukankan      html  css  js  c++  java
  • Python作业篇 day02

     作业

    知识点回顾:

    1、变量名的规范

    2、简述 ascii unicode utf-8 的关系

    3、简述 位与字节的关系

    4、‘我是帅哥’  在utf-8编码用几个字节  ,在gbk用几个字节

    逻辑运算练习

    print( 6 or 2 >1  ) #6
    print(3 or 2 >1) # 3
    print(0 or 5 < 4) #False ?  
    print(5 < 4 or 3) #3
    
    print(2>1 or 6) #True
    print(3 and 2 >1) # True
    
    print(0 and 3 >1) #0
    print(2 > 1 and 3) #True
    print(3 > 1 and 0) # 0   ?
    print(3 > 1 and 2 or 2 <3 and 3 and 4 or 3>2) #2

    代码练习

    #1、 查看  name = input('>>>') 中name 的 数据类型,如果是int 转成int 类型数据
    
    name = input(">>>")
    print(type(name))     #打印数据类型
    

      

    # 2、使用while循环输入 1 2 3 4 5 6 8 9 10 ,如果为7 不输出

    #while循环
    count = 1;
    while count < 11 :

    if count != 7:
    print(count)

    count +=1

    #for 循环
    for i in range(101):
    if i % 2 ==1:
    print(i)

      

    #3、用户登陆(三次机会重试)
    username = 'zhangsan'
    password = '123456'
    count = 3
    while count >0 :
        name = input("请输入名字:")
        if name == username :
            ps = input("请输入密码:")
            if password == ps:
                print("恭喜您,登入成功")
                break
            else :
                count -= 1
                if count == 0:
                   print('没有机会了')
                else:
                    print('密码错误,还有' + str(count) + '次机会')
        else:
            count -= 1
            if count ==0 :
                print('没有机会了')
            else:
                print('账号错误,还有' + str(count) + '次机会')
    

      

    #41-2+3-4...-76+78-79...+98-99  计算结果
    import math
    k = -1
    result = 0
    j = 1

    for i in range(100):
    if i == 77:
    continue
    result = result + i * math.pow(k, j)
    j += 1

    print(result)
  • 相关阅读:
    freemarker 遍历 hashmap 到select option
    三分钟跑起jsblocks
    hibernate_@GeneratedValue
    跑github上的Symfony项目遇到的问题2
    Activiti使用过程_1
    Symfony官方视频教程
    跑github上的Symfony项目遇到的问题
    剧本杀
    随遇而安
    开发者职场心得
  • 原文地址:https://www.cnblogs.com/xibanqiu/p/11634403.html
Copyright © 2011-2022 走看看