Why are variables of train and test data defined using the capital letter (in Python)?
The X (and sometimes Y) variables are matrices.

In some math notation, it is common practice to write vector variable names as lower case and matrix variable names as upper case. Often these are in bold or have other annotation, but that does not translate well to code. Either way, I believe that the practice has transferred from this notation. 

You may also notice in code, when the target variable is a single column of values, it is written y, so you have X, y

Of course, this has no special semantic meaning in Python and you are free to ignore the convention. However, because it has become a convention, it may be worth maintaining if you share your code.