d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
OldScore = d.get('Alice')
if(OldScore != None):
print(OldScore)
d['Alice'] = 60
print(d)
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
OldScore = d.get('Alice')
if(OldScore != None):
print(OldScore)
d['Alice'] = 60
print(d)
2021-09-30
L=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
S=[89, 72, 88, 79, 99]
n=len(S)
for i in range(n):
for j in range(i+1,n):
if S[i]<S[j]:
t=S[j]
S[j]=S[i]
S[i]=t
name = L[j]
L[j] = L[i]
L[i] = name
print(S)
print(L)
S=[89, 72, 88, 79, 99]
n=len(S)
for i in range(n):
for j in range(i+1,n):
if S[i]<S[j]:
t=S[j]
S[j]=S[i]
S[i]=t
name = L[j]
L[j] = L[i]
L[i] = name
print(S)
print(L)
2021-09-28
# Enter a code
names=['Alice','Bob','Candy','David','Ellena']
score=[89,72,88,79,99]
names.sort()
names.reverse()
score.sort()
score.reverse()
A=[names,score]
print(A)
names=['Alice','Bob','Candy','David','Ellena']
score=[89,72,88,79,99]
names.sort()
names.reverse()
score.sort()
score.reverse()
A=[names,score]
print(A)
2021-09-28
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name_set = set(names)
new_names = []
i = input("输入一个名字:")
new_i = i.title()
if new_i in names:
print('Ture')
name_set = set(names)
new_names = []
i = input("输入一个名字:")
new_i = i.title()
if new_i in names:
print('Ture')
2021-09-27
最新回答 / qq_慕九州0566793
你用b循环a,a是list,里面的值是int,每次循环只有一个int值L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]for a in L: x=a[0] y=a[1] z=a[2] c=x*y*2+x*z*2+y*z*2 print c
2021-09-25
def sub_sum(L):
js_sum=0
os_sum=0
for num in L:
if num%2==0:
os_sum+=num
else:
js_sum+=num
return js_sum,os_sum
print(sub_sum([1,2,3,4,5,6,7,8,9,10]))
另外:任务里面的参考答案是错误的!!!
js_sum=0
os_sum=0
for num in L:
if num%2==0:
os_sum+=num
else:
js_sum+=num
return js_sum,os_sum
print(sub_sum([1,2,3,4,5,6,7,8,9,10]))
另外:任务里面的参考答案是错误的!!!
2021-09-23