Calculating a risk score
To round out this chapter, we will add one final method to our growing RiskQuestionnaire
class:
def calculateScore(self): print("Risk Score:") myTotalScore = 0 for question in self.questions: for answer in question.answers: if (answer.selected == True): myTotalScore = myTotalScore + ( answer.score * question.weight) print(answer.answerText + ": " + str( answer.score * question.weight)) print("Total Risk Score: " + str(myTotalScore) + "\n")
In...