for i in range(10):
if i == 0:
continue
else:
for j in range(i+1):
if j == 0:
continue
else:
print(i, "*", j, "= ", j * i)
print('\n'.join([' '.join([f"{j}x{i}={i*j}" for j in range(1, i + 1)]) for i in range(1, 10)]))
list1 = ['physics', 'chemistry', '1799', '2000']
list2 = [1, 2, 3, 4, 5]
list3 = ['a', 'b', 'c', 'd']
print(list1)
print(list2)
print(list3)
list4 = [] # 空列表
list4.append('加油!') # 使用append()方法添加元素
print(list4)
list4.append('RunAble')
print(list4)
print(list4[1])
list5 = [2,3,5,7,8,66,77]
print(list5[-2])
print(list5[-4])
print(list5[-6])
print(list5[1:4]) # 含头不含尾
print(list5[1:-2])
list6 = ['Google', 'RunAble', '1997', 2021]
print('第三个元素为:', list6[2])
list6[2] = '替换值'
print('替换后的第三个元素为:', list6[2])
list = ['Google', 'RunAble', 1997, 2000,2323,353,46,5758,454]
list0 = [1,2,3,4]
print(len(list0))
list1 = [5,6,7,8]
print(list0 + list1)
print(list0*4)
print(3 in list0)
for x in[1,2,3]:print(x,end="")
L = ['hello', 'world', 'big', 'data']
print(L[1:3])
squares = [1,2,3,4]
squares += [5,6,6,7]
print(squares)
list = [144,6,8,65,34,56,63,22,45,33,22,33,22]
print(len(list))
print(max(list))
print(min(list))
print(list.count(22))
list1 = list.copy()
print(list1)
list.sort()
print(list)
print(list.reverse())
tup1 = ('Google', 'RunAble', 1997, 2000)
tup2 = (1,2,3,4,5)
tup3 = 'a','b','c','d' # 不加括号亦可以
print(tup3, type(tup3)) # ('a', 'b', 'c', 'd') <class 'tuple'>
tup4 = (50)
print(tup4,type(tup4)) # 50 <class 'int'>
tup5 = (50,)
print(tup5,type(tup5)) # (50,) <class 'tuple'>
tup6 = ['Google', 'RunAble', 1997, 2000]
tup7 = [1, 2, 3, 4, 5, 6, 7 ]
print(tup6[3])
print(tup7[1::2])
tup8 = (12,23,34)
tup9 = ('abc','xyz')
dict1 = {1001:'值一',1002:'值二',1003:'值三',1004:'值四',1005:'值五'}
print(dict1, type(dict1))
print(len(dict1))
print(dict1.keys())
print(dict1.values())
print(dict1.items())
dict2 = {1006:'新加值六',1007:'新加值七',1008:'新加值八',1001:'新加值一'}
dict1.update(dict2)
print(dict1)