L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
N = [89,72,88,79,99]
dictA=dict(zip(L,N))
dictB=sorted(dictA, key=dictA.get, reverse = True)
print(dictB)
N = [89,72,88,79,99]
dictA=dict(zip(L,N))
dictB=sorted(dictA, key=dictA.get, reverse = True)
print(dictB)
2020-11-26
最赞回答 / 慕仙9354813
首先,s,d是定义在sub_sum()这个函数中的,这个函数对外只有l一个参数。当sub_sum()这个函数定义结束时,外部是无法访问内部的s,d如果你想打印s和d,要改成这样:def sub_sum(l): s=0 d=0 for i in l: if i%2==0: s=s+i else: d=d+i i=i+1 print(s) print(d)l=[1,2,3,4,5,6,7,8,9...
2020-11-26
# Enter a code
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(squre, 2))
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(squre, 2))
2020-11-23
# Enter a code
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(wide, 2))
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(wide, 2))
2020-11-23
l=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
l[0]='Ellena'
l[1]='Alice'
l[-1]='Bob'
print(l)
l[0]='Ellena'
l[1]='Alice'
l[-1]='Bob'
print(l)
2020-11-23
print(r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.''')
print('\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.')
Whether it's nobler in the mind to suffer.''')
print('\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.')
2020-11-21
# 方法1
list = [i ** 2 for i in range(1, 10)]
print(sum(list))
# 方法2
list2 = [*range(1, 10)]
def square_of_sum(list):
sum = 0
for num in list:
sum += num**2
return sum
sum = square_of_sum(list2)
print(sum)
list = [i ** 2 for i in range(1, 10)]
print(sum(list))
# 方法2
list2 = [*range(1, 10)]
def square_of_sum(list):
sum = 0
for num in list:
sum += num**2
return sum
sum = square_of_sum(list2)
print(sum)
2020-11-21
# 方法1
list = [i**2 for i in range(1,10)]
print(sum(list))
# 方法2
list2 = [*range(1,10)]
def square_of_sum(list):
sum = 0
for num in list:
sum += num
return sum
sum = square_of_sum(list2)
print(sum)
list = [i**2 for i in range(1,10)]
print(sum(list))
# 方法2
list2 = [*range(1,10)]
def square_of_sum(list):
sum = 0
for num in list:
sum += num
return sum
sum = square_of_sum(list2)
print(sum)
2020-11-21