最新回答 / yaoqz
for x in [ 1,2,3,4,5,6,7,8,9 ]: for y in [0,1,2,3,4,5,6,7,8,9 ]: if x<y: print x*10+yprint多加一个tab键
2020-05-03
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
2020-05-03
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
count=len(d)
for i in d.itervalues():
sum +=i
print sum/count
sum = 0.0
count=len(d)
for i in d.itervalues():
sum +=i
print sum/count
2020-05-01
def average(*args):
if len(args) == 0:
return 0.0
else:
sums=0.0
for i in args:
sums=sums+i
return sums/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
if len(args) == 0:
return 0.0
else:
sums=0.0
for i in args:
sums=sums+i
return sums/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2020-05-01
def square_of_sum(L):
sums=0
for i in L:
sums+=i*i
return sums
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sums=0
for i in L:
sums+=i*i
return sums
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2020-05-01
sums=0
for x in range(1,101):
for xx in range(1,101):
if(x==xx):
sums+=x*xx
print sums
for x in range(1,101):
for xx in range(1,101):
if(x==xx):
sums+=x*xx
print sums
2020-05-01
最新回答 / 慕先生9411764
可以,因为list是可迭代的,tuple中如果存在的dict也是可以新加入元素或删除元素的
t = ("a", "b", ["x", "y"]) print(t[2]) t[2].append("z") print(t) ==> ('a', 'b', ['x', 'y', 'z']) t[2].pop() print(t) ==> ('a', 'b', ['x', 'y'])
2020-04-30