jeudi 21 septembre 2017

Selecting random scores from a .txt file and finding their average (Python)

I've been trying to select scores at random from a .txt file and then finding the average of these randomly selected scores. Below is an example:

 James, 0.974

 Harry, 0.971

 Ben, 0.968

 Tom, 0.965

 George, 0.964

For the sake of simplicity, I'd just like to select 2 scores at random to start with. See below:

 James, 0.974

 Harry, 0.971 <---

 Ben, 0.968

 Tom, 0.965 <---

 George, 0.964

The end result would then be (Harry and Tom):

Average = 0.968

Can anyone help? I've been using 'split', 'import random' etc. But I'm not great at putting these all together.

Thanks very much




Aucun commentaire:

Enregistrer un commentaire