這是我的第一篇文章在這裏計算器,這用Python做一個節目是我的第一次。我想打一個程序要求用戶學生輸入姓名,然後能夠更多信息添加到學生的程序繼續運行。理想我想用戶選擇多少學生有選擇多少個回合的玩法,給他們的名字,分配的分數,並在最後輸出的最終得分和每個學生的平均分。如何使用用戶輸入來確定程序的工作方式?
這是我目前:
name_students = list()
num_students = input("How many students?: ")
competitionRounds = input("How many rounds: ")
score_students = list()
myList = name_students
for i in range(1, int(num_students) + 1):
name_students.append(input("Student Name: "))
print(name_students)
for i in range (1, int(competitionRounds)):
print(input(name_students [0] + " Total Score for each round: "))
這是程序的運行方式:
How many student?: 3 #Have the user input answers to these questions
How many rounds?: 2
Student Name: Nick
Student Name: Bob
Student Name: Lisa
Nick Total Score for each round:
我一直想把它索要像
Nick Total Score for round 1:
Bob Total score for round 1:
Lisa Total score for round 1:
Nick Total score for round 2:
列出每一個名字
等等
我感謝任何回覆的人。
---編輯--- 所以,我現在有問題,取用戶輸入的數字,並將它們按用戶放置的名稱加在一起。
我的預期結果是: 尼克總得分的回合1:2 鮑勃總得分輪1:3 麗莎總得分輪1:1 尼克總成績爲第2輪:2 鮑勃總得分輪2:3 麗莎總成績爲第2輪:對於所有輪1個 尼克總比分:4 等
目前我的代碼如下所示:
name_students = list()
num_students = input("How many students?: ")
competitionRounds = input("How many rounds: ")
score_students = []
myList = name_students
total_scores = 0, []
for i in range(1, int(num_students) + 1):
name_students.append(input("Student Name: "))
for i in range (1, int(competitionRounds) +1):
for j in range(len(name_students)):
score_students.append(input(name_students [j] + " Total Score for round " + str(i) +": "))
for i in range (1,int(competitionRounds) +1):
for t in range(len(score_students)):
print(name_students + score_students + total_scores)
請妥善縮進代碼。 – Antimony