Practice 1:打印列表
1 for i in range(5): 2 for j in range(5): 3 print(i,end="\t") 4 print()
Practice 2:打印九九乘法表
1 s = "" 2 for i in range(1,10): 3 for j in range(1,i+1): 4 s= i*j 5 print("{0}*{1}={2}".format(j,i,s),end="\t") 6 print()
Practice 3:用列表和字典存储下列信息,并打印出表中工资高于15000的数据
姓名 | 年龄 | 薪资 | 城市 |
a | 18 | 20000 | 北京 |
b | 19 | 30000 | 上海 |
c | 20 | 10000 | 深圳 |
1 tb = [] 2 r1 = dict(name="a",age=18,salary=20000,city="北京") 3 r2 = dict(name="b",age=18,salary=30000,city="上海") 4 r3 = dict(name="c",age=18,salary=10000,city="深圳") 5 6 tb = [r1,r2,r3] 7 for i in tb: 8 if i.get('salary')>15000: 9 print(i)