一 、python历史背景
1、创始人:Guido van rossum 龟叔
2、创始时间:1989年
3、特点:简单,明确, 优雅
4、解释型语言,高级语言
二、Python的基本数据类型
1、布尔类型 True False
print (10 > 5)
输出 True
print ( 10 > 20 )
输出 False
2、数值类型 int (155) float(30.55)
(1)、单目运算符:~ + - (正负)
(2)、算术运算符:** , / , * , // , % , + , -
(3)、位运算符: & , | , ^ , >> , <<
(4)、关系运算符: > >= , < <= , == , !=
(5)、赋值运算符: = , += , -= , /= , *= , //= , %= , **=
(6)、身份运算符 : is , is not
(7)、成员运算符 : in , not in
(8)、逻辑运算符: not , and , or
3、函数:
(1)、int()
(2)、pow()
(3)、divmod()
(4)、abs()
字符串
str :' ' , " " , ' ' ' ' ' ' , " " " " " "
运算符: + , / , *n , in , not in
有序的 索引(0) "abc" index :索引
s[index] 0<= index <len(s) - len(s) <= index <= -1
切片:
s[start :end : step]
start <= index < end ---------> index +=step
函数:
len():求字符串长度
max():最大值
min():最小值
. index():索引
. count():统计
. format() : %s 字符串 , %d 数值 , %f 浮点
三、读入和输出
input() : 读入
age = int(input("请输入年龄:"))
print() : 输出
print ( 3+4)