A hard-coded solution without lists:
return ((num%10) <= 2) or ((num%10) >= 8)
A generalized version, as some commenters asked for:
return ((num%mult) <= diff) or ((num%mult) >= (mult-diff))
The times I got for this were: (using existing answers to compare against)
>>> import timeit
>>> timeit.timeit('(128%10) in range(0,3) or (128%10) in range(8,10)')
>>> timeit.timeit('(128%10) in [0,1,2,8,9]')
>>> timeit.timeit('(128%10) <= 2) or ((128%10) >= (10-2))')
So, it seems a little faster than even the hard-coded list.
I thought about adding a variable to store the value of
(num%mult), but figure that a smart compiler should automatically put that in a temporary variable for reuse.