これに構文エラーのある質問があることは知っていますが、ここで問題を把握することはできません。なぜ私に以下の構文エラーが出るのですか?構文エラーリストの理解
更新:55 モジュール= namedtuple( 'モジュール'、 'コードのタイトルECTS')
BB1_MODULES = {
'BB103': Module('BB103', 'Computer Systems', 5),
'BB111': Module('BB111', 'Web Design', 5),
'BB112': Module('BB112', 'Digital Innovation', 5),
'BB123': Module('BB123', 'Computer Programming I', 10),
'BB124': Module('BB124', 'Computer Programming II', 10),
'BB343': Module('BB343', 'Networks and Internet', 5),
'BB434': Module('BB434', 'Operating Systems', 5),
'BB543': Module('BB543', 'Problem Solving', 5),
'BB432': Module('BB432', 'IT Mathematics', 10)}#ects
class Student(object):
def __init__(self, idnum, surname, firstname, mods=CA1_MODULES):
self.__idnum = idnum
self.__surname = surname
self.__firstname = firstname
self.__mods = mods
self.__marks = {code: 0 for code in self.__mods.keys()} #returm a list of module codes #dict comprehension
# self.__total_credits
self.__total__credits = sum[mod.ects for mod in self.__mods.values()]
def __str__(self):
name = '{} : {} {}'.format(self.__idnum,
self.__firstname,
self.__surname)
uline = '-' * len(name)
results = '\n'.join([code + ' : ' + self.__mods[code].title +
' : ' + str(self.__marks[code])
for code in sorted(self.__mods.keys())])
pm = 'Precision mark: {:.2f}'.format(self.precision_mark())
if self.passed():
outcome = 'Pass'
elif self.passed_by_compensation():
outcome = 'Pass by compensation'
else:
outcome = 'Fail'
return '\n'.join([name, uline, results, pm, outcome])
def add_mark(self, module, mark):
self.__marks[module]=mark
def precision_mark():
[self.__marks[mod] * self.__mods[code].ects for code in self.__mods.keys()]/self.__total_credits
def passed():
return min(self__marks.values()) >= 40
def passed_by_compensation():
if self.precision_mark() <45:
return False
sum([self.__mods[code].ects for code in self.__mods.keys() if self.marks[code] < 40]) > self.__total_credits/6:
return False
return min(self.marks.__values()) >= 35
self.__total__credits = sum[mod.ects for mod in self.__mods.values()]
^
#SyntaxError: invalid syntax
#self.__total__credits = sum[mod.ects for mod in self.__mods.values()]
親の合計(自己.__ mods.values())のmod.ects) 'または' sum(mod。self .__ mods.values())のmod.ects 'が – styvane