python(1)
(1)数据类型
- booleans
- int/float
- str
- list
list 的使用
areas=[11,22,33,44,55]
————0 1 2 3 4
_______-5 -4 -3 -2 -1
(1)
areas[0]=11
areas[-1]=55
print(2:4) :输出a[2],a[3],左闭右开
print(:2):自动视作左边为a[0],会输出11,22
! print(2:):也会输出55,不写的话最后一个也会被包括
(2)子集
x = [["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"]] print(x[2][0])
输出结果是d
(3)数组中元素的删除
areas = [“hallway”, 11.25, “kitchen”, 18.0,“chill zone”, 20.0, “bedroom”, 10.75,
“bathroom”, 10.50, “poolhouse”, 24.5, “garage”, 15.45]
想删掉areas[-4:-2]的元素
但若是直接输入del (areas[-3],areas[-4])或者del(areas[10:11])无法实现
因为是逐个删除的,这样的话删掉了24.5后,poolhouse就变成了areas[-3]
(4)数组中元素的变动——Inner workings of lists
(2)数据类型的转换
input:
income = 30.23
print("I managed to get $“+str(income) +"this month.")
output:
I managed to get $30.23 this month.
(3)运算
- **: 幂运算
- / :求模运算