运行结果截图:
import random
def fun():
i = 50
lis = []
while i > 0:
num1 = random.randint(0, 20)
num2 = random.randint(0, 20)
regstr = "{}+{}=".format(num1, num2)
if regstr not in lis:
lis.append(regstr)
i -= 1
else:
continue
return lis
lis = fun()
print('学号:*** 姓名:***')
for index, num in enumerate(lis):
if (index + 1) % 5 == 0:
print(num)
else:
print(num, end='\t')