def square_of_sum(L):
b=[]
for a in L:
a=a**2
b.append(a)
return sum(b)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
b=[]
for a in L:
a=a**2
b.append(a)
return sum(b)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-08-01
r'''print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''调皮,编码可以直接改上面的utf-8为unicode,如果使用u'''data'''天知道会出什么错
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''调皮,编码可以直接改上面的utf-8为unicode,如果使用u'''data'''天知道会出什么错
2019-07-31
L = []
for b in range(1,101):
a=b**2
L.append(a)
print sum(L)
for b in range(1,101):
a=b**2
L.append(a)
print sum(L)
2019-07-31
s='Python was started in 1989 by “guido”. /n Python is free and easy to learn. '
2019-07-30
x1=1 d=3 n=3 xn=x1+(n-1)*3
x100=x1+99d print(x100)
s=100(x1+x100)/2
x100=x1+99d print(x100)
s=100(x1+x100)/2
2019-07-30
sum = 0
x = 0
while True:
x = x + 1
if x % 2 == 0:
continue
if x > 100:
break
sum = sum + x
print sum
x = 0
while True:
x = x + 1
if x % 2 == 0:
continue
if x > 100:
break
sum = sum + x
print sum
2019-07-30
def move(n, a, b, c):
if n==1:
print a,'-->',c
return
move (n-1, a, c, b)
move (1, a, b, c)
move (n-1, b, a, c)
move(4, 'A', 'B', 'C')
if n==1:
print a,'-->',c
return
move (n-1, a, c, b)
move (1, a, b, c)
move (n-1, b, a, c)
move(4, 'A', 'B', 'C')
2019-07-30
def square_of_sum(L):
a = 0
n = 0
for x in L:
while len(L)>n:
a = L[n]*L[n] + a
n = n+1
else:
return a
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
a = 0
n = 0
for x in L:
while len(L)>n:
a = L[n]*L[n] + a
n = n+1
else:
return a
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-07-30