def square_of_sum(L):
L1=[]
for name in L:
L1.append(name * name)
return sum(L1)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
L1=[]
for name in L:
L1.append(name * name)
return sum(L1)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-05-16
已采纳回答 / 慕后端1274496
你的x是tuple,想输出ok,set里的元素也应该是tuple类型: weekdays = set([('MON', 'TUE', 'WEN', 'THU', 'FRI', 'SAT', 'SUN')]) x = 'MON', 'TUE', 'WEN', 'THU', 'FRI', 'SAT', 'SUN' if x in weekdays: print('input ok') else: print('input error')
2019-05-16
sum = ['A','B','C','D']
sum2 = ['E','F','G','H']
sum3 = ['a','b','c','d']
for x in sum:
for y in sum2:
for z in sum3:
print x + y + z
sum2 = ['E','F','G','H']
sum3 = ['a','b','c','d']
for x in sum:
for y in sum2:
for z in sum3:
print x + y + z
2019-05-15
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-05-15
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x = x * 2
n = n + 1
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum = sum + x
x = x * 2
n = n + 1
if n > 20:
break
print sum
2019-05-15
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
2019-05-15