大家好,欢迎来到IT知识分享网。
- 后面学习循环后就会简化很多
# coding:utf-8
work = {
}
# 1
one_value = (1,)
one_key = 1
work[str(one_key)] = one_value
print(work)
# 2
two_key = 2
two_value = []
two_value.append(1)
two_value.append(2)
work[str(two_key)] = two_value
# 3
three_key = 3
three_value = []
three_value.append(1)
three_value.append(2)
three_value.append(3)
work[str(three_key)] = three_value
print(work)
# 4
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
# 5
temp_five = [1, 2, 3, 4, 5]
five_key = 5
five_value = []
five_value.extend(temp_five)
work[str(five_key)] = five_value
print(work)
# 6
temp_six = [1, 2, 3, 4, 5, 6]
six_key = 6
six_value = []
six_value.extend(temp_six)
work[str(six_key)] = six_value
# 7
temp_seven = [1, 2, 3, 4, 5, 6, 7]
seven_key = 7
seven_value = []
seven_value.extend(temp_seven)
work[str(seven_key)] = seven_value
# 8
temp_eight = {
1, 2, 3, 4, 5, 6, 7, 8}
eight_key = 8
eight_value = []
eight_value.extend(temp_eight)
work[str(eight_key)] = eight_value
# 9
temp_nine = (1, 2, 3, 4, 5, 6, 7, 8, 9)
nine_key = 9
nine_value = []
nine_value.extend(temp_nine)
work.update({
str(nine_key): list(nine_value)})
print(work)
_keys = work.keys()
keys = list(_keys)
print(keys)
one = keys[0]
one_value = work.pop(one)
print(one,one_value)
one_key =int(one)
print('{} * {} = {}'.format(one_key, one_value[0], one_key*one_value[0]))
two = keys[1]
two_value = work.pop(two)
print('{} * {} = {}'.format(two, two_value[0], int(two)*two_value[0]), end=' ')
print('{} * {} = {}'.format(two, two_value[1], int(two)*two_value[1]))
three = keys[2]
three_value = work.pop(three)
print('{} * {} = {}'.format(three, three_value[0], int(three)*three_value[0]), end=' ')
print('{} * {} = {}'.format(three, three_value[1], int(three)*three_value[1]), end=' ')
print('{} * {} = {}'.format(three, three_value[2], int(three)*three_value[2]))
four = keys[3]
four_value = work.pop(four)
print('{} * {} = {}'.format(four, four_value[0], int(four)*four_value[0]), end=' ')
print('{} * {} = {}'.format(four, four_value[1], int(four)*four_value[1]), end=' ')
print('{} * {} = {}'.format(four, four_value[2], int(four)*four_value[2]), end=' ')
print('{} * {} = {}'.format(four, four_value[3], int(four)*four_value[3]))
five = keys[4]
five_value = work.pop(five)
print('{} * {} = {}'.format(five, five_value[0], int(five)*five_value[0]), end=' ')
print('{} * {} = {}'.format(five, five_value[1], int(five)*five_value[1]), end=' ')
print('{} * {} = {}'.format(five, five_value[2], int(five)*five_value[2]), end=' ')
print('{} * {} = {}'.format(five, five_value[3], int(five)*five_value[3]), end=' ')
print('{} * {} = {}'.format(five, five_value[4], int(five)*five_value[4]))
six = keys[5]
six_value = work.pop(six)
print('{} * {} = {}'.format(six, six_value[0], int(six)*six_value[0]), end=' ')
print('{} * {} = {}'.format(six, six_value[1], int(six)*six_value[1]), end=' ')
print('{} * {} = {}'.format(six, six_value[2], int(six)*six_value[2]), end=' ')
print('{} * {} = {}'.format(six, six_value[3], int(six)*six_value[3]), end=' ')
print('{} * {} = {}'.format(six, six_value[4], int(six)*six_value[4]), end=' ')
print('{} * {} = {}'.format(six, six_value[5], int(six)*six_value[5]))
seven = keys[6]
seven_value = work.pop(seven)
print('{} * {} = {}'.format(seven, seven_value[0], int(seven)*seven_value[0]), end=' ')
print('{} * {} = {}'.format(seven, seven_value[1], int(seven)*seven_value[1]), end=' ')
print('{} * {} = {}'.format(seven, seven_value[2], int(seven)*seven_value[2]), end=' ')
print('{} * {} = {}'.format(seven, seven_value[3], int(seven)*seven_value[3]), end=' ')
print('{} * {} = {}'.format(seven, seven_value[4], int(seven)*seven_value[4]), end=' ')
print('{} * {} = {}'.format(seven, seven_value[5], int(seven)*seven_value[5]), end=' ')
print('{} * {} = {}'.format(seven, seven_value[6], int(seven)*seven_value[6]))
eight = keys[7]
eight_value = work.pop(eight)
print('{} * {} = {}'.format(eight, eight_value[0], int(eight)*eight_value[0]), end=' ')
print('{} * {} = {}'.format(eight, eight_value[1], int(eight)*eight_value[1]), end=' ')
print('{} * {} = {}'.format(eight, eight_value[2], int(eight)*eight_value[2]), end=' ')
print('{} * {} = {}'.format(eight, eight_value[3], int(eight)*eight_value[3]), end=' ')
print('{} * {} = {}'.format(eight, eight_value[4], int(eight)*eight_value[4]), end=' ')
print('{} * {} = {}'.format(eight, eight_value[5], int(eight)*eight_value[5]), end=' ')
print('{} * {} = {}'.format(eight, eight_value[6], int(eight)*eight_value[6]), end=' ')
print('{} * {} = {}'.format(eight, eight_value[7], int(eight)*eight_value[7]))
nine = keys[8]
nine_value = work.pop(nine)
print('{} * {} = {}'.format(nine, nine_value[0], int(nine)*nine_value[0]), end=' ')
print('{} * {} = {}'.format(nine, nine_value[1], int(nine)*nine_value[1]), end=' ')
print('{} * {} = {}'.format(nine, nine_value[2], int(nine)*nine_value[2]), end=' ')
print('{} * {} = {}'.format(nine, nine_value[3], int(nine)*nine_value[3]), end=' ')
print('{} * {} = {}'.format(nine, nine_value[4], int(nine)*nine_value[4]), end=' ')
print('{} * {} = {}'.format(nine, nine_value[5], int(nine)*nine_value[5]), end=' ')
print('{} * {} = {}'.format(nine, nine_value[6], int(nine)*nine_value[6]), end=' ')
print('{} * {} = {}'.format(nine, nine_value[7], int(nine)*nine_value[7]), end=' ')
print('{} * {} = {}'.format(nine, nine_value[8], int(nine)*nine_value[8]))
{'1': (1,)}
{'1': (1,), '2': [1, 2], '3': [1, 2, 3]}
{'1': (1,), '2': [1, 2], '3': [1, 2, 3], '4': [1, 2, 3, 4], '5': [1, 2, 3, 4, 5]}
{'1': (1,), '2': [1, 2], '3': [1, 2, 3], '4': [1, 2, 3, 4], '5': [1, 2, 3, 4, 5], '6': [1, 2, 3, 4, 5, 6], '7': [1, 2, 3, 4, 5, 6, 7], '8': [1, 2, 3, 4, 5, 6, 7, 8], '9': [1, 2, 3, 4, 5, 6, 7, 8, 9]}
['1', '2', '3', '4', '5', '6', '7', '8', '9']
1 (1,)
1 * 1 = 1
2 * 1 = 2 2 * 2 = 4
3 * 1 = 3 3 * 2 = 6 3 * 3 = 9
4 * 1 = 4 4 * 2 = 8 4 * 3 = 12 4 * 4 = 16
5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25
6 * 1 = 6 6 * 2 = 12 6 * 3 = 18 6 * 4 = 24 6 * 5 = 30 6 * 6 = 36
7 * 1 = 7 7 * 2 = 14 7 * 3 = 21 7 * 4 = 28 7 * 5 = 35 7 * 6 = 42 7 * 7 = 49
8 * 1 = 8 8 * 2 = 16 8 * 3 = 24 8 * 4 = 32 8 * 5 = 40 8 * 6 = 48 8 * 7 = 56 8 * 8 = 64
9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 9 * 6 = 54 9 * 7 = 63 9 * 8 = 72 9 * 9 = 81
Process finished with exit code 0
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/15851.html