How do I programmatically find the core version? How do I programmatically find the Drupal core version running a site?
I found this example in MetatagNodeTranslationTest.

To find the drupal version in your code, 

\Drupal::VERSION


will return it.

If you need to compare

if (floatval(\Drupal::VERSION) &lt;= 8.3) {
  // do some stuff.
}