The most common answer is:
# fill in this function to return the total of the three judges' scores!
judges_scores=(10,10,10)
def calculate_score(judges_scores):
return judges_scores[0]+judges_scores[1]+judges_scores[2]
print (calculate_score(judges_scores))
This function for calculating the total score from three judges in a diving contest is correct. It properly adds up the scores from the three elements of the judges_scores
tuple.
However, the function lacks proper indentation, which is essential in Python. Let’s correct the indentation:
def calculate_score(judge_scores):
num1, num2, num3 = judge_scores
return (judge_scores[2] + judge_scores[0] + judge_scores[1])
print(calculate_score((5, 8, 10)))
Leave a comment