zoukankan      html  css  js  c++  java
  • Python9-day2 作业

    下列结果是什么?

    6 or 2 >1     6

    3 or 2 > 1  3

    0 or 5<4  false

    5 < 4 or 3  3

    2 >1 or 6 True

    3 and 2 > 1  True

    0 and 3 > 1 0

    2 > 1 and 3  3

    3 > 1 and 0  0

    3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2    2

    2 or false and fasle and 3 and 4 or 3>2

    2 or  fase and 3 and 4 or 3>2 2

    2 or  fase or 3>2

    2 or 3>2

    2

    简述变量命名规范

     由数字、字母、下划线组成,不能以数字开通

    name=input(">>>") name变量是什么数据类型?

     变量的数据类型是str(字符串)

    if 条件数据基本结构?

     if 条件:

      结果

    while循环语句基本结构?

     while 条件:

      结果

    写代码:计算1-2+3....+99中除了88以外所有数的总和

    count = 1
    sum = 0

    while count <= 99:
    if count == 88:
    pass
    elif count % 2 != 0:
    sum=sum+count
    else:
    sum =sum-count
    count +=1
    print(sum)

    用户登录(三次输错机会)且每次输入错误时显示剩余错误次数(提示:使用字符串格式化)

    name = "cisco"
    password = "cisco"
    count =1
    while count<=3:
    name =input("pls your username: ")
    password=input("pls your password: ")
    if name=="cisco" and password =="cisco":
    print("Your Win! !!!!")
    break
    if count ==3:
    print('''This is last chance!!!!!!!,You input %s times'''%(count))
    break
    print('''你已经输入%s次了,很可惜!!!!!!!!!!!!!''' %(count))
    if count ==2:
    print("You have last chance!!!!!!!!!!!")
    count+=1

    简述ascii、unicode、utf-8编码关系?

    简述位和字节的关系?

    “⽼男孩”使⽤UTF-8编码占⽤⼏个字节?使⽤GBK编码占⼏个字节?

    制作趣味模板程序需求:等待⽤户输⼊名字、地点、爱好,根据⽤户的名字和爱好进⾏任意现实

    等待⽤户输⼊内容,检测⽤户输⼊内容中是否包含敏感字符?如果存在敏感字符提示“存在敏感字符请重新输⼊”,并允许⽤户 重新输⼊并打印。敏感字符:“⼩粉嫩”、“⼤铁锤”

    看代码书写结果: a = 1>2 or 4<7 and 8 == 8 print(a)

    continue和break区别?

    Bit,Bytes,Kb,Mb,Gb,Tb之间的转换关系。

    Unicode,utf-8,gbk,每个编码英文,中文,分别用几个字节表示

  • 相关阅读:
    public、private、protected继承的规则
    派生类对象的构造函数与析构函数
    类的保护成员
    派生类覆盖(修改)基类成员
    条款03:尽可能使用const
    处理类与类之间的关系
    继承派生基本概念
    条款02:尽量以const,enum,inline替换#define(宁可编译器替代预处理器)
    Redis持久化AOF和RDB对比
    Memcached取模算法
  • 原文地址:https://www.cnblogs.com/zhangtengccie/p/python.html
Copyright © 2011-2022 走看看