How many lines of code does Moodle core have?
The latest release - 3.4 has about 800k non-comment, non-blank lines of PHP code and about 90.7k non-comment, non-blank lines of JS code.
How did that change from version to version?
See the metrics from Moodle 2.6 to Moodle 3.4 for the PHP code:
How was that calculated?
To analyze the core Moodle I have removed from it: 3-rd party libraries, "build" and "lang" directories. I have then used cloc to calculate the number of non-comment and non-empty lines of code.