導航:首頁 > 編程語言 > python累加所有課程總分

python累加所有課程總分

發布時間:2022-11-12 00:34:31

㈠ 如何用python中while語句寫出全班總成績和平均成績

al=[1,2,3,4,5,6] #全班成績
sumv=0;x=0
while x<=len(al):
sumv+=x
x+=1

print(sumv,sumv/len(al))

㈡ python3計算每個學生的總成績

數量少的話可以用列表循環來實現
數量多的話就要用pandas來實現了

㈢ 關於python的簡單問題

代碼如下:

classstudent:
def__init__(self,studentName):
self.studentName=studentName
self.score=[]

defscoreEntry(self,languageScore,mathScore):
self.score.append(languageScore)
self.score.append(mathScore)

deftotalScoreCalculation(self):
a=self.score[0]+self.score[1]
print("{}的總分是:{}分".format(self.studentName,a))

s1=student("李雷")
s1.scoreEntry(100,100)
s1.totalScoreCalculation()

運行結果:

望採納

㈣ Python實驗題目,求助大佬

以下是代碼:

all_tuple = []

sum_stu = int(input('請輸入一共有多少個學生:'))

while(sum_stu>0):

a = input('請輸入學生名字:')

class1 = float(input('第一門課的成績:'))

class2 = float(input('第二門課的成績:'))

class3 = float(input('第三門課的成績:'))

score = class1 + class2 + class3

mid = score/3

one_tuple = (a,class1,class2,class3,mid,score)

all_tuple.append(one_tuple)

sum_stu -= 1

sorted_list = sorted(all_tuple,key=lambda x:x[5],reverse=True)

sum_stu = 1

for i in sorted_list:

print('第',sum_stu,'名',i[0],':',end='')

print('平均分:',i[4],',總分:',i[5])

sum_stu += 1

㈤ python順序表

本問題回答如下:你可以根據自己的需求稍微改動一下
# -*- coding: cp936 -*-
class StuInfo:
def __init__(self):
self.Stu=[{"Sno":"1","Sname":"姓名","ChineseScore":64,"MathsScore":34,"EnglishScore":94,"ComputerScore":83},
{"Sno":"2","Sname":"姓名","ChineseScore":44,"MathsScore":24,"EnglishScore":44,"ComputerScore":71},
{"Sno":"3","Sname":"姓名","ChineseScore":74,"MathsScore":35,"EnglishScore":74,"ComputerScore":93},
{"Sno":"4","Sname":"姓名","ChineseScore":94,"MathsScore":54,"EnglishScore":24,"ComputerScore":73}]
self.attribute={"Sno":"學號",
"Sname":"姓名",
"ChineseScore":"語文成績",
"MathsScore":"數學成績",
"EnglishScore":"英語成績",
"ComputerScore":"計算機成績"
}
def _add(self):
'''添加'''
singleInfo={}
for i in self.attribute:
if "Score" in i:
singleInfo[i]=int(raw_input(self.attribute[i]+"\n"))
else:
singleInfo[i]=raw_input(self.attribute[i]+"\n").strip()
self.Stu.append(singleInfo)
print "添加成功OK"
for i in singleInfo:
print i,"=",singleInfo[i]

def _del(self):
"""刪除學號為Sno的記錄"""
Sno=raw_input("學號:\n")
self.Stu.remove(self.__getInfo(Sno))
print "刪除成功OK"

def _update(self):
"""更新數據"""
Sno=raw_input("學號\n").strip()
prefix="修改"
updateOperate={"1":"ChineseScore",
"2":"MathsScore",
"3":"EnglishScore",
"4":"ComputerScore"}
for i in updateOperate:
print i,"-->",prefix+self.attribute[updateOperate[i]]
getOperateNum=raw_input("選擇操作:\n")
if getOperateNum:
getNewValue=int(raw_input("輸入新的值:\n"))
record=self.__getInfo(Sno)
record[updateOperate[getOperateNum]]=getNewValue
print "修改"+record["Sname"]+"的"+str(updateOperate[getOperateNum])+"成績=",getNewValue,"\n成功OK"

def _getInfo(self):
"""查詢數據"""
while True:
print "1->學號查詢 2->條件查詢 3->退出"
getNum=raw_input("選擇:\n")
if getNum=="1":
Sno=raw_input("學號:\n")
print filter(lambda record:record["Sno"]==Sno,self.Stu)[0]
elif getNum=="2":
print "ChineseScore 語文成績;","MathsScore 數學成績;","EnglishScore 英語成績;","ComputerScore 計算機成績;"
print "等於 ==,小於 <, 大於 > ,大於等於 >=,小於等於<= ,不等於!="
print "按如下格式輸入查詢條件 eg: ChineseScore>=60 "
expr=raw_input("條件:\n")
Infos=self.__getInfo(expr=expr)
if Infos:
print "共%d記錄"%len(Infos)
for i in Infos:
print i
else:
print "記錄為空"
elif getNum=="3":
break
else:
pass
def __getInfo(self,Sno=None,expr=""):
"""查詢數據
根據學號 _getInfo("111111")
根據分數 _getInfo("EnglishSorce>80")"""
if Sno:
return filter(lambda record:record["Sno"]==Sno,self.Stu)[0]
for operate in [">=",">","<=","<","==","!="]:
if operate in expr:
gradeName,value=expr.split(operate)
return filter(lambda record: eval( repr(record[gradeName.strip()])+operate+value.strip()) ,self.Stu)
return {}

def _showAll(self):
"""顯示所有記錄"""
for i in self.Stu:
print i

@staticmethod
def test():
"""測試"""
_StuInfo=StuInfo()
while True:
print "1->錄入數據 2->修改數據 3->刪除數據 4->查詢數據 5->查看數據 6->退出"
t=raw_input("選擇:\n")
if t=="1":
print "錄入數據"
_StuInfo._add()
elif t=="2":
print "修改數據"
_StuInfo._update()
elif t=="3":
print "刪除數據"
_StuInfo._del()
elif t=="4":
print "查詢數據"
_StuInfo._getInfo()
elif t=="5":
print "顯示所有記錄"
_StuInfo._showAll()
elif t=="6":
break
else:
pass
if __name__=="__main__":
StuInfo.test()
希望本次回答對你的提問有所幫助謝謝

㈥ python輸入五門成績,求總分和平均分

有5個學生,每個學生修4門課程,求每個學生所有成績的總分和平均分
#include <stdio.h>
#define First 5
#define Second 6
int main(void)
{
float a[First][Second],sum=0.0;
int i,j,cnt=1;
printf("分別輸入5名同學的4門成績:\n");
for(i=0;i<First;i++)
{
for(j=0;j<Second-2;j++)
{
scanf("%f",&a[i][j]);
}
}
for(i=0;i<First;i++)
{
for(j=0;j<Second-2;j++)
{
sum+=a[i][j];
}
a[i][4]=sum;
a[i][5]=a[i][4]/4.0;
sum=0; //初始化
}
for(i=0;i<First;cnt++,i++)
{
printf("學生%d的成績情況\t\t\t總成績\t平均成績\n",cnt);
for(j=0;j<Second;j++)
{
printf("%.2f\t",a[i][j]);
}
printf("\n");
}
}

㈦ python程序設計作業球大佬指點迷津

這都屬於項目范圍了。100行代碼,懸賞300-500財富值我都不幹。浪費三四小時幫你做作業

啥指點迷津,這是要源碼。實現難度不難,寫一堆代碼不累死

㈧ Python設計 依次輸入三名同學五門功課得分,計算並輸出每位同學的總分,並將每位同學的總分保存在列表

一次瘦肉,三名同學五門功課的得分,並輸出每位同學的總分,並將每位同學總分保存在列表中,你可以用自動求和的方式。

㈨ 怎麼用python做出下面的內容

l = []
While True:
....c_in = innput()
....if c_in.isdigit():
........l.append(eval(c_in))
....else:
........break
print('最高分:', max(l))
print('最低分:', min(l))
print('總分:', sum(l))
print('平均分:', sum(l)/len(l))

㈩ 用python怎麼寫出輸入語文和數學成績,求出其總分和平均數

摘要 1.輸入學生學號:

閱讀全文

與python累加所有課程總分相關的資料

熱點內容
游戲源碼搭建一條龍 瀏覽:192
宋金pdf 瀏覽:807
伺服器為什麼需要內存池 瀏覽:526
php與jquery開發實例 瀏覽:289
編程大世界故事漫畫 瀏覽:983
北漂程序員出車禍 瀏覽:914
亞馬遜為什麼用雲端伺服器 瀏覽:65
程序員審核職位 瀏覽:385
德龍空調壓縮機 瀏覽:780
紅旗app如何注冊新賬戶 瀏覽:360
慣導pdf 瀏覽:606
c程序員的平均工資 瀏覽:58
微小店源碼 瀏覽:801
編譯原理答題題庫 瀏覽:169
ubuntu編程入門 瀏覽:301
antbuild命令 瀏覽:771
怎麼訂閱伺服器 瀏覽:593
視頻專用加密器哪個好用 瀏覽:295
app無法使用網路哪裡設置 瀏覽:847
紅旗linux怎麼安裝 瀏覽:136