How do you calculate elo? I am starting a chess club at my school, and I want to create a Python program to calculate and store Elo ratings for each player. I am confident I can program it, but I just need to know:

How do you calculate Elo?

What i am looking for:


Equations to calculate expected outcome for each player.
Equations to calculate elo change using this.
How to deal with a draw.
How the value of K can be calculated, or suggestions for a static value of K which would work for students.


So far the best explanation I have found is the League of Legends rating system explained in this video (which happens to be the same system used in chess).
Here you have some more information about Elo system that maybe it's useful for you.

Arpad Elo designed his system assuming a normal distribution in the results achieved by the players with a standard deviation of 200 rating points. So he used a logistic function to calculate the expected results by a player. The actual function (actually a table is used with minimal differences with this function) is:

WEa = 1 / (1 + 10^((Rb-Ra)/400)), rounded to two decimal digits


WEa is the expected result for player a, while Rb and Ra are the ratings of both players. As you can see in a game between two players having 400 points of difference in rating the chances of winning the game are 10:1.

After the game(s) expected and actual results of a player are compared, so players performing better than their expected results increase their ratings, and players performing worse decrease them. To do that the difference between expected and actual results is multiplied by a constant factor K. This constant value has to be small enough to make the system stable and avoid reflecting the very last results only, but large enough to be able to track players evolution. I guess a good value would be between 20 and 30, Jeff Sonas for example suggest 24 as the optimum value, while FIDE handbook points that rating stabilizes after 70 games (K10), 35 games (K20) and 18 games (K40), maybe these numbers can be useful for you to set your own K value.

Using a greater K value the very first few games can help your students to reach an approximate rating quickly and then you can change to a smaller K value.