Calculating scores for predictions of football scores I am writing a program which calculates the scores for participants of a small "Football Score Prediction" game.

Rules are:


if the match result(win/loss/draw) is predicted correctly: 1 point
if the match score is predicted correctly(exact score): 3 points (and +1 point because 1st rule is automatically satisfied)


Score is calculated after every round of matches (10 matches in a round).

The program I've written is as follows:

import numpy as np
import re
players = {0:'Alex',1:'Charlton',2:'Vineet'}
results = np.array(range(40),dtype='a20').reshape(4,10)
eachPrediction = np.array(range(20),dtype='a2').reshape(2,10)
score = np.zeros(3)
correctScore=3
correctResult=1
allPredictions = []
done = False

def takeFixtures():
    filename='bplinput.txt'
    file = open(filename)
    text = file.readlines()
    fixtures = [line.strip() for line in text]
    file.close()
    i=0
    for eachMatch in fixtures:
        x=re.match("(.*) ([0-9]+) ?- ?([0-9]+) (.*)", eachMatch)
        results[0,i]=x.group(1)
        results[1,i]=x.group(2)
        results[2,i]=x.group(3)
        results[3,i]=x.group(4)
        i+=1


def takePredictions(noOfParticipants):
    for i in range(0,noOfParticipants):
        print("Enter predictions by "+players[i]+" in x-y format")
        for i in range(0,10):
            eachFixturePrediction = raw_input("Enter prediction for "+results[0,i]+" vs "+results[3,i]+": ")
            x=eachFixturePrediction.split('-')
            eachPrediction[0,i]=str(x[0])
            eachPrediction[1,i]=str(x[1])
        allPredictions.append(eachPrediction)


def scoreEngine():
    for i in range(0,len(players)):
        for j in range(0,10):
            resultH=int(results[1,j])
            resultA=int(results[2,j])
            result=resultH-resultA
            predictionH=int(allPredictions[i][0][j])
            predictionA=int(allPredictions[i][1][j])
            pResult = predictionH-predictionA
            if result == pResult or (result&lt;0 and pResult&lt;0) or (result&gt;0 and pResult&gt;0):
                score[i]+=correctResult
                if resultH==predictionH and resultA==predictionA:
                    score[i]+=correctScore



noOfParticipants=len(players)
takeFixtures()
takePredictions(noOfParticipants)
scoreEngine()
print("Scores are:")
print(score)
for player in players:
    print(players[player]+" has scored "+ str(score[player])+" points" )


The file used to take list of fixtures looks like this:

West Bromwich Albion 0-1 Tottenham Hotspur
Manchester City 2-2 Liverpool
Queens Park Rangers 0-0 Norwich City
Arsenal 1-0 Stoke City
Everton 3-3 Aston Villa
Newcastle United 3-2 Chelsea
Reading 2-1 Sunderland
West Ham United 1-0 Swansea City
Wigan Athletic 2-2 Southampton
Fulham 0-1 Manchester United


I want advice on how this program can be improved in any way (decreasing the code/ making it efficient).
Style

The first thing to do is to follow PEP 8: it's a style guide that says how you should indent your code, name your variables, and so on. For example, prefer results[0, i] = x.group(1) to results[0,i]=x.group(1).

Files

Opening files in Python should be done using the with idiom: your file is then guaranteed to be close correctly. takeFixtures now becomes:

def takeFixtures():
    with open('bplinput.txt') as file:
        for eachMath in file:
            x=re.match("(.*) ([0-9]+) ?- ?([0-9]+) (.*)", eachMatch.strip)
            results[0,i]=x.group(1)
            results[1,i]=x.group(2)
            results[2,i]=x.group(3)
            results[3,i]=x.group(4)
            i+=1


Data structures

I you didn't use numpy, you could have written results[i] = x.groups(), and then used zip(*results) to transpose the resulting matrix. More generally, as pointed out by Josay, you should use Python data structures, and only switch to numpy if you find out that this is where the inefficiency lies.

Formatting

The last thing that the other reviewers didn't mention is that concatenating strings is poor style, and format() should be preferred since it's more readable and more efficient:

for player in players:
    print("{} has scored {} points".format(players[player], score[player]))