xir0905
2020-10-09 13:41
names=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
grade=[89, 72, 88, 79, 99]
for i in range(4):
for j in range(i+1,5):
if grade[j]>grade[i]:
names[i],names[j]=names[j],names[i]
grade[i],grade[j]=grade[j],grade[i]
print(names)
name = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
score = [89, 72, 88, 79, 99]
scores = [89, 72, 88, 79, 99]
score.sort(reverse = True)
rank = []
for i in range(len(score)):
for j in range(len(score)):
if score[i] == scores[j]:
rank.append(name[j])
print(rank)
L = ['Alice','Bob','Candy','David','Ellena']
L[0]='Ellena'
L[1]='Alice'
L[2]='Candy'
L[3]='David'
L[4]='Bob'
print(L)
Python3 入门教程(新版)
154156 学习 · 1075 问题
相似问题