課程
/后端開發
/Python
/Python3 入門教程(新版)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L[0]='Ellena'
L[1]='Alice'
L[4]='Bob'
print(L)
2020-10-25
源自:Python3 入門教程(新版) 5-7
正在回答
# Enter a code
# coding:utf-8
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
scores = [89, 72, 88, 79, 99]
templateNames = []
templateScores = [89, 72, 88, 79, 99]
scores.sort(reverse=True)
print("降序排列后的成績:" + str(scores))
index_Score = 0
index_TemplateScore = 0
for score in scores:
? ? index_TemplateScore = 0
? ? for templateScore in templateScores:
? ? ? ? if score == templateScore:
? ? ? ? ? ? templateNames.append(names[index_TemplateScore])
? ? ? ? index_TemplateScore += 1
print("排列后的名字:" + str(templateNames))
N = [89,72,88,79,99]
dictA=dict(zip(L,N))
dictB=sorted(dictA, key=dictA.get, reverse = True)
print(dictB)
慕俠1360900
qq_老老宋_0 回復 慕俠1360900
對的 不用全部替換
qq_謝謝惠顧_2
舉報
python3入門教程,讓你快速入門并能編寫簡單的Python程序
2 回答為啥倒敘是-3 卻把‘candy’替換掉了?
3 回答不用if不可以嗎?
1 回答python下載了 cmd顯示不是內部和外部命令 也不是可運行的程序
6 回答輸出為什么不可以是漢字
2 回答直接替換最新的數組就可以了哇,多次的新增很麻煩哇
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2021-03-12
# Enter a code
# coding:utf-8
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
scores = [89, 72, 88, 79, 99]
templateNames = []
templateScores = [89, 72, 88, 79, 99]
scores.sort(reverse=True)
print("降序排列后的成績:" + str(scores))
index_Score = 0
index_TemplateScore = 0
for score in scores:
? ? index_TemplateScore = 0
? ? for templateScore in templateScores:
? ? ? ? if score == templateScore:
? ? ? ? ? ? templateNames.append(names[index_TemplateScore])
? ? ? ? index_TemplateScore += 1
print("排列后的名字:" + str(templateNames))
2020-11-26
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)
2020-10-26
對的 不用全部替換