课程
/后端开发
/Python
/初识Python
请问如果想显示为1*1=1 2*2=4.。。。。100*100=100000怎么实现呢?
按照题目要求修改了很久做不出
2018-08-22
源自:初识Python 7-2
正在回答
def square_of_sum(L): sum = 0 for l in L: sum = sum + l ** 2 return sum print square_of_sum([1, 2, 3, 4, 5]) print square_of_sum([-5, 0, 5, 15, 25])
L = [] L = range(1,101) def sum(L): sum = 0 for i in L: sum = sum + i * i return sum print sum(L)
x=1 while x<=100: L=x * x print x,'*',x,'=',L x=x+1
你是说这样吗?
上面这个答案很不错,但是问题里100*100=10万(100000)是什么鬼?
for i in range(1, 101): print i, '*', i, '=', i * i
for m in range(1,101):
for n in range(1,101):
if m==n:
print m,'*',n,'=',m*n
举报
学python入门视频教程,让你快速入门并能编写简单的Python程序