python的数据类型
数值,浮点数,字符串,布尔类型,列表,元组,集合,字典等数据类型。
数据类型那些可以做四则运算?
int和float类型
a = 1
b = 2
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(a ** b)
print(a // b)
a = 1.5
b = 2.0
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(a ** b)
print(a // b)
列表
list = ['red', 'green', 'blue', 'yellow', 'white', 'black']
print( list[0] )
print( list[1] )
print( list[-6] )
元组
tup1 = ('Google', 'Runoob', 1997, 2000)
tup2 = (1, 2, 3, 4, 5, 6, 7 )
print ("tup1[0]: ", tup1[0])
print ("tup2[1:5]: ", tup2[1:5])
字典
# 使用大括号 {} 来创建空字典
emptyDict = {}
# 打印字典
print(emptyDict)
# 查看字典的数量
print("Length:", len(emptyDict))
# 查看类型
print(type(emptyDict))