Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function, named SoccerPoints. which takes as argument a vector of game r

ID: 3563892 • Letter: W

Question

Write a function, named SoccerPoints. which takes as argument a vector of game results, where I indicates a win. 0 indicates a tic, and - 1 indicates a loss. The function should then compute the total number of points where a win is assigned 3 points, a tic is assigned 1 point, and a loss is assigned 0 points. For example, SocccrPoints (| I I 0-1 I -1 0 11) should compute 14. Write a function, named SumDigits. which takes as an argument a positive integer less than 10.000 and then returns the sum of the digits of that number. For example. SumDigits(l53) should return 9. As another example. SumDigits(2039) should return 14.

Explanation / Answer

def SoccerPoints(vector):
point = 0
for v in vector:
if v == 1:
point += 3
elif v == -1:
point += 1
return point

def SumPoint(num):
sum = 0
for i in str(num):
sum += int(i)
return sum

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote