pyhton9x9乘法表

work = {}  #创建一个字典

one_value = (1,)  #值
one_key = 1       #键
work[str(one_key)] = one_value   #键值对给work字典

two_key = 2
two_value = []
two_value.append(1)   #增加值
two_value.append(2)
work[str(two_key)] = two_value

three_key = 3
three_value = []
three_value.append(1)          
three_value.append(2)
three_value.append(3)
work[str(three_key)] = three_value

four_key = 4
four_value = []
four_value.append(1)
four_value.append(2)
four_value.append(3)
four_value.append(4)
work[str(four_key)] = four_value

temp_five = {1,2,3,4,5}      #直接给5个值的列表
five_key = 5
five_value = []
five_value.extend(temp_five)     #将这5个值直接加入five_value
work[str(five_key)] = five_value
print(work)


_keys = work.keys()
keys = list(_keys)
print(keys)

one = keys[0]
one_value = work.pop(one)
print(one,one_value)
print('{} * {} = {}'.format(int(one),one_value[0], int(one) *one_value[0] ) )

two = keys[1]
two_value = work.pop(two)   #删除
print('{} * {} = {}'.format(int(two),two_value[0],int(two)*two_value[0]), end= ' ')#让2x2在同一行
print('{} * {} = {}'.format(int(two),two_value[1],int(two)*two_value[1]))

#34略

five =keys[4]
five_value = work.pop(five)
print('%s * %s = %s' %(five, five_value[0], int(five)*five_value[0]), end = ' ')
print('%s * %s = %s' %(five, five_value[1], int(five)*five_value[1]), end = ' ')
#...

在这里插入代码片
```for i in range(1,10):
  for j in range(1,i+1):
  print('{}*{}={}'.format(i,j,i*j),end = ' ')
  print(' ')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值