咕咕鸡鸽鸽
发表于 2019-3-6 12:38:16
def fun94(list1):
score = sorted(list1,key=lambda x:x,reverse=True)
count = 1
print("{}{}{}".format(count,score,score))
for each in range(1,len(score)):
if score != score:
count += 1
print("{}{}{}".format(count,score,score))
score = [('A', 80), ('B', 86), ('C', 92), ('D', 87), ('E', 88), ('F', 85),
('G', 86), ('H', 89), ('I', 88), ('J', 94), ('K', 94), ('L', 80),
('M', 83), ('N', 80), ('O', 88), ('P', 94), ('Q', 82), ('R', 84),
('S', 96), ('T', 100), ('U', 82), ('V', 81), ('W', 94), ('X', 81),
('Y', 89), ('Z', 92)]
print(fun94(score))
Geoffreylee
发表于 2020-3-19 14:15:58
def f_94(lst: list):
lst.sort(key=lambda x: (x, -ord(x)), reverse=True)
for i, j in enumerate(lst):
rank = i if j == lst else i+1
print(rank, j, j)
小贤啊哦
发表于 2020-5-6 10:55:27
def fun94(s):
sorted_s = sorted(list(set( for x in s])))[::-1]
for i in sorted_s:
for j in s:
if j == i:
print('%s %s %s'%(sorted_s.index(i)+1,j,j))
Sweet丶
发表于 2020-5-6 11:13:52
score = [('A', 80), ('B', 86), ('C', 92), ('D', 87), ('E', 88), ('F', 85),
('G', 86), ('H', 89), ('I', 88), ('J', 94), ('K', 94), ('L', 80),
('M', 83), ('N', 80), ('O', 88), ('P', 94), ('Q', 82), ('R', 84),
('S', 96), ('T', 100), ('U', 82), ('V', 81), ('W', 94), ('X', 81),
('Y', 89), ('Z', 92)]
score = sorted(score,key=lambda x:x)[::-1]
小陨aoq
发表于 2020-8-1 17:25:07
def order(score):
# 将列表按成绩降序排序
score = sorted(score, key=lambda x: x, reverse=True)
# 当前名次以及上一位同学的名次
rank, last_rank = 1, 0
# 上一位同学的成绩
last_score = 120
# 最终的排名结果
results = []
for each in score:
# 判断当前同学成绩是否跟上一位同学相等
if each != last_score:
# 若不等,排到新的名次
results.append((rank, each, each))
last_rank = rank
last_score = each
rank += 1
else:
# 若相等,跟上一位同学一样名次
results.append((last_rank, each, each))
rank += 1
# 循环打印排名
for info in results:
print(info, info, info)
19971023
发表于 2020-8-8 12:00:43
1
z2x2c8
发表于 2020-8-20 23:57:17
看看
freeck2013
发表于 2020-8-21 16:02:05
def chooseSecond(element):
return element
def score():
score = [('A', 80), ('B', 86), ('C', 92), ('D', 87), ('E', 88), ('F', 85),
('G', 86), ('H', 89), ('I', 88), ('J', 94), ('K', 94), ('L', 80),
('M', 83), ('N', 80), ('O', 88), ('P', 94), ('Q', 82), ('R', 84),
('S', 96), ('T', 100), ('U', 82), ('V', 81), ('W', 94), ('X', 81),
('Y', 89), ('Z', 92)]
j = 0
score.sort(key=chooseSecond,reverse = True)
for i in range(0,len(score)):
if i>0:
if score == score:
j += 1
else:
j = 0
print(str(i-j+1)+' '+score+' '+str(score))
else:
print(str(i+1)+' '+score+' '+str(score))
if __name__ == '__main__':
score()
junsitu9159
发表于 2020-8-22 02:04:44
看答案
aironeng
发表于 2020-12-8 08:57:26
学习
holiday_python
发表于 2021-4-19 07:23:25
看看
qq1151985918
发表于 2021-4-19 07:26:09
{:10_249:}。