Yes, you most certainly can pet your ball python. Snake scales go in one direction, and you should always pet with and not against the grain of their scales. This means that you should be petting in a downward motion from the direction of their head to the direction of their tail.
Many, though not all, ball pythons are head-shy, meaning they do not like to be stroked on their head, and will recoil or potentially even become aggressive if they are touched on their head because of the amount they dislike it. Many head-shy ball pythons will also not like to be stroked on their necks. Other ball pythons will be perfectly fine letting a human stroke them on their heads and necks, but be careful around a new ball python in case it is in fact head-shy. Sometimes, with increased handling, a ball python is able to go from being head shy to being perfectly fine with a human stroking its head. Yet this takes a lot of effort, patience, and increased handling time on the part of the owner (not too much! maybe 30-40 minutes a day, though it has to be consistent and nearly every day or else the ball python may become unaccustomed to you again). This does not happen with all ball pythons, however, so if you have a head shy ball python, there is no guarantee that it will ever be okay with you touching its head.
Ball python skin may deceptively look slimy like a frog’s skin, but it most definitely is not. Ball pythons have extremely smooth skin that is very nice to the touch. The vast majority of ball pythons are indifferent to whether you pet them or not, so long as they are being petted below the neck.
Although they won’t necessarily enjoy it, they also will certainly not be displeased with you for petting them, or feel uncomfortable with it, so you can confidently pet your ball python if they seem to be fine with that kind of handling (as the vast majority will be).
As much as is physically possible, do not handle or try to pet a ball python that has recently eaten. It may regurgitate if it is moved or becomes too anxious, so keep your distance for some time while your pet digests. Once it becomes active again, you can take this as a sign that it has digested enough and is fine with being held and petted.