python Lesson

1, bool value types only two values (True, False) # Boolean value
 
 
        Conversion between the three types of data str int bool
 
 
        str () int () bool () function itself is built
 
 
        str ----> int a = "6484684" element must be a number, otherwise an error
 
 
        str -----> bool empty string is not empty all False True
 
 
         int -----> bool 0 is False, True all non 0
 
 
         bool ---> int True 1 False is 0
 
 
         bool---->str "True" , " False"
 
 
 
 
2. # comparison operators
 
 
         > < >= <= !=
 
 
       == comparison values ​​are the same two objects
 
 
       is the comparison is the same memory address
 
 
       Look at memory address method id (Object)
 
      
 
 
3, logical operators and or not
 
 
        x and y, x is true, the value is y, x is false, the value of x
 
 
        x or y, x is true, that is, the value of x, x is false, y is the value
 
 
       Comparison operator precedence over logical operators
 
 
       ()>not >and >or
 
 
         If the priority at the same level, from left to right execution
 
 
 
 
 
4, 算数运算符 + - * / %取余 ** 平方 // 取整
 
 
5, 成员运算符 in, not in
 
 
现在学的只有字符串 x in y, y中是否包含x
 
 
6, 赋值运算符
 
 
      = += -= *= /= %= **= //=
 
 
 
复合赋值运算符
 
 
       在python中这种对a进行加法之后再赋值给a的情况,我们叫做 自加,常见的操作当然还有自减
 
 
     a = 6
 
 
     a +=1
 
 
     a -=3
 
 
  学到的内置函数
 
 
print()
 
 
input()
 
 
type()
 
 
int()
 
 
str()
 
 
bool()
 
 
id()
 
 
 
小数据池: 只在str,int中存在的
 
 
小数据池作用:(为了节省内存而存在)
 
 
数据 -5 ---256 之间的值共用一个内存地址
 
 
str ,空 或者一位(包括特殊字符) 也是共用一个内存
 
 
如果多位并且包括特殊字符不共用内存
 
 
 
为空时,true
 
 
 
 
在python交互式时,变量可以直接输出,不用借助print
 
 
 
 
 
 
 
 
 
 

Guess you like

Origin www.cnblogs.com/yuzui/p/11687829.html