dimanche 20 juin 2021

Python: Extract info from a matrix (if/for-statement) (assignment related)

I am trying to make a program that calculates the average scoring in a match. The input should be a matrix, where columns should be players and rows their scoring. Or the other way around. However there are conditions:

  1. If a player has only 1 number (scoring) = that is their scoring-value. Say x x 6, then 6 is their number.

  2. If the player has 2 or more: disregard the lowest scoring, and calculate the average between the remaining: Here, the code should refer to and work with a rounding function that was made earlier. def roundScore(scoring):

  3. If the player has a score of 0, 0 will always be the number, regardless of other scorings.

The code should start and end like this

def calculateFinalScore(scoring):
# put code here
return scoringFinal

The output should then be a vector, containing the final scoring for each player.

How can I solve this? I've been thinking of referring to the columns and their content with if/for/elif-statements. But I have a hard time thinking how to do this and then there's the issue of merging def roundScore(scoring):into the new function and coding.

Hope it makes sense!

Aucun commentaire:

Enregistrer un commentaire