Oh, I thought it was different, but yours makes more sense.
[Spoiler=How SuperDyl solved Q2]
First off, each four digit number must not be though of as an individual number, but instead as 4 individual digits (Not 2581, instead it's 2, 5, 8, and 1).
Each digit corresponds to a different value. Adding each digits' values together returns the answers shown. We must compare different numbers to get these values.
1111, 2222, 3333, 5555, and 7777 each equal 0, meaning that 1, 2, 3, 5, and 7 each equal 0 individually.
0000, 6666, and 9999 each equal 4. Just take the number of digits then and divide that by 4 (4 (the answer) / 4 digits = 1). This returns the average value of the numbers, which is 1 for each of the digits 0, 6, and 9.
Now we have the values for 0, 1, 2, 3, 5, 6, 7, and 9. We are missing 4 and 8. There are no four digit numbers with 4 in them, so 8 is the only number left. From any number with an 8 digit we can find its value. For example, 8809 = 6. The 0 and 9 both equal 1, so we can subtract both from the answer (8809 = 6 - 1 - 1; 88 = 4). Now we just find the average just like earlier (4 (the answer) / 2 digits = 2) to find that 8's value is 2.
Now we as complete a key we can:
1, 2, 3, 5, 7 = 0
0, 6, 9 = 1
8 = 2
4 is unknown.
The number that needs solving is 2581. If we change the values of each we get: 0 + 0 + 2 + 0 = 2.
I thought the system was based off of division, as 1, 2, 3, 5, 7 each equal zero and are all primes (except one, which is more like a prime number than not). This doesn't fully work, and @TheTastyNacho 's answer of being from the loops makes more sense and also explains why 4 doesn't appear in any four digit number as it can have a closed off area, but also may not depending on the font.
[/Spoiler]