# 九九乘法表 for m in range(1,10): for n in range(1,m+1): print("{0}*{1}={2}".format(n,m,(n*m)),end="\t") print()#换行
# 1-100的总和,奇数项和,偶数项和 sum_all = 0 sum_odd = 0 sum_even = 0 for i in range(1,101): sum_all += i if i % 2 == 1: sum_odd += i else: sum_even += i print("1-100的总和为{0},奇数项和为P{1},偶数项和为{2}".format(sum_all,sum_odd,sum_even))
# 使用列表和字典存储表格的数据 r1 = dict(name = "张三", age = 18, city = "北京", salary = 12000) r2 = dict(name = "李四", age = 20, city = "上海", salary = 15000) r3 = dict(name = "王五", age = 28, city = "深圳", salary = 18000) tb = [r1,r2,r3] for i in tb: if i.get("salary") >=15000: print(i)
标签:salary,九九乘法,sum,偶数,嵌套循环,print,100 From: https://www.cnblogs.com/st1379/p/17776450.html