You should make your life easier and print a hit counter at the end, which I suspect the variable p stores.
As noted in the comments, you can eliminate a lot of calculations using a more reasonable algorithm.
1: check if the number is even (num% 2) (if so, not just)
2: While the divisor is less than or equal to the square root, and prime = True, the test divisor
3: , 2, ( num% 2)
, , , , , , ... , . , 10000 .
100, 99 . 2 . 2,3,5,7,9... 5 99.