私はこのようなスコアを含む一連のリストを持っています。名前の後の最初の数字は学生ステータスです。 1 =新入生2 =年生3 = Jr.4 = Srの数字を含むリストを並べ替える
Ablao 3 74 96 72 88 71 80 83 77 90 88 95 71 76 94 80 74 98 77
Anderson 3 76 92 98 95 92 76 93 97 85 76 85 93 82 88 75 84 92 77
Aspinwall 1 86 74 78 97 86 94 73 95 74 91 75 94 83 99 83 78 88 96
Bacon 4 72 95 81 80 89 88 100 87 87 81 79 77 75 83 87 96 72 95
私は、このようなラボの平均の高い、低い平均など様々な統計を計算する関数を作成する必要があります。、プログラムの平均など年に基づい学生の私はすでに平均化のために作成された関数を持っています。私はちょうど学生の年までにデータをソートすることに問題があります。
これまでのところ、私が持っている、ここで
All_Years=[]
Freshman=[]
Sophomores=[]
Juniors=[]
Seniors=[]
def make_lists_of_status():
if (student_status==1):
Freshman.append(student_scores)
elif (student_status==2):
Sophomores.append(student_scores)
elif (student_status==3):
Juniors.append(student_scores)
elif (student_status==4):
Seniors.append(student_scores)
elif(student_status==1 or 2 or 3 or 4):
All_Years.append(student_scores)
def statistics_func():
user_stat_choice='x'
print("This option is used for viewing statistics sorted by the year of the student")
print("Please select one of the following options:")
print("(a) for All Years, (b) for Freshman, (c) for Sophomores, (d) for Juniors, (e) for Seniors")
user_stat_choice=print(input("Enter your choice here:"))
if(user_stat_choice=='a'):
print ("Hi/Low/Mean of all weighted scores is:",max(All_Years),min(All_Years),(sum(All_Years)/len(All_Years)))
print ("Hi/Low/Mean of all lab averages is:")
print ("Hi/Low/Mean of all program averages is:")
が出力ファイルからこれを読むには統計
This option is for viewing statistics sorted by the year of student.
Please select one of the following options:
a for ALL YEARS
b for FRESHMAN
c for SOPHMORES
d for JUNIORS
e for SENIORS
Enter your choice here: a
For All Students:
High/Low/Mean of all Weighted Scores: 89.9/81.6/85.41883333333335
High/Low/Mean of all Lab Averages: 89.6/79.6/85.28333333333332
High/Low/Mean of all Program Averages: 98.33333333333333/ 71.66666666666667/85.90555555555554
Back to the Main Menu....
によってあなたは「学生の年でデータをソートする」ことで、正確に何を意味するかを使用して行うことができますか?サンプルの入力と出力を追加できればうれしいでしょう。 –
サンプルを追加しました@VedangMehta – Rachel
また、 'All_Years'リストは最後の' elif'ステートメントに到達することができないので、nullになります – cdhagmann