AKA2pac 发表于 2017-9-13 12:48:50

mark

曾经子曰 发表于 2017-9-13 15:02:48

看看如何解体

超好吃的泡面 发表于 2017-9-13 16:51:00

{:5_91:}

瓦蓝 发表于 2017-9-13 20:31:31

{:10_243:}

加油呀,python 发表于 2017-9-13 21:02:22

Ssssss

咖喱168 发表于 2017-9-13 22:15:52

不会啊

懒惰有只猫 发表于 2017-9-13 22:42:12

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)]

for i in range(0,len(score),1):
    for j in range(i + 1,len(score),1):
      if score < score:
            temp = score
            score = score
            score = temp

num = 1
for i in range(0,len(score),1):
    if (i != 0 and score > score):
      num = num + 1
    print (num, score)

liuwenqi 发表于 2017-9-14 09:52:55

score.sort(key = lambda item:item, reverse=True)
rank = 1
for i in range(len(score)):
   
    if i == 0:
      print(rank, score)
    else:
      if score == score:
            print(rank, score)
      else:
            rank = i+1
            print(rank, score)

1 ('T', 100)
2 ('S', 96)
3 ('J', 94)
3 ('K', 94)
3 ('P', 94)
3 ('W', 94)
7 ('C', 92)
7 ('Z', 92)
9 ('H', 89)
9 ('Y', 89)
11 ('E', 88)
11 ('I', 88)
11 ('O', 88)
14 ('D', 87)
15 ('B', 86)
15 ('G', 86)
17 ('F', 85)
18 ('R', 84)
19 ('M', 83)
20 ('Q', 82)
20 ('U', 82)
22 ('V', 81)
22 ('X', 81)
24 ('A', 80)
24 ('L', 80)
24 ('N', 80)

jen104 发表于 2017-9-14 10:42:02

dasdfsadfasdf

zhsworld 发表于 2017-9-14 17:25:13

score.sort(key=lambda n: n, reverse=True)
for m,n in enumerate(score):
      c = m+1 if n!=score else c
      print(c,n,n)

lihuayuan 发表于 2017-9-17 19:13:53

好难

shigure_takimi 发表于 2017-12-5 10:41:47

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)]

def orderScore(score):
    orderedScore = sorted(score, key = lambda s:s, reverse = True)
    order =
    for i in range(1, len(score)):
      if orderedScore == orderedScore:
            order = order
    for i,j in zip(order, orderedScore):
      print(i, j, j)

orderScore(score)

776667 发表于 2017-12-25 16:37:59

def fun94(score):
    sorted_score = sorted(list(set( for x in score])))[::-1]
    for i in sorted_score:
      for j in score:
            if j == i:
                print('%s %s %s'%(sorted_score.index(i)+1,j,j))
               
if __name__ == '__main__':
    fun94(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)])

yjsx86 发表于 2018-1-30 06:50:06

score.sort(key=lambda item: item,reverse=True)
temp = 1
for i in range(len(score)):
    if i == 0 or score != score:
      score = (temp,)+score
    else :
      score = (score,) + score
    temp += 1
print(score)

不失微笑 发表于 2018-1-30 13:09:00

谢谢

lovesword 发表于 2018-1-30 13:48:15

from itertools import groupby
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,reverse=True)
sum=1
for index, v in enumerate(groupby(map(lambda x:x,score))):
    tmp = list(v)
    for index_,i in enumerate(tmp):
      print sum,score,i
    sum += len(tmp)

ciager 发表于 2018-1-30 14:05:34

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)]
n = 1
L = sorted(score,key=lambda x:x,reverse=True)
for i in range(len(L)-1):
    if L > L:
      print(n,L)
      n = n + 1
    elifL == L:
      n = n
      print(n,L)

TheKernel 发表于 2018-2-2 18:49:01

写出来了:
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)]

for i in range(0, len(score) - 1):
    k = i
    for j in range(i, len(score)):
      if score < score:
            k = j
    if k != i:
      temp = score
      score = score
      score = temp

print("%d %c %d" % (1, score, score))
rank = 2
for i in range(1, len(score)):
    if score == score:
      print("%d %c %d" % (rank, score, score))
    else:
      rank = i + 1
      print("%d %c %d" % (rank, score, score))

新手潘包邮 发表于 2018-4-24 00:00:11

jerryxjr1220 发表于 2017-9-8 06:38


大佬, 能分享下你的学习经验吗,你的解答怎么总是这么强,能不能给我指下怎么学习啊

咕咕鸡鸽鸽 发表于 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))
页: 1 [2] 3
查看完整版本: Python:每日一题 94(答题领鱼币)