All snakes can swim - their natural moment facilitates swimming, of course some are much better at it than others, just unless panicked they don't typically drown if they can get out of the water easily. That said, terrestrial species like ball pythons don't often naturally seek out swimmable water so may be stressed / fearful / panic / or at least not enjoy it. Some may.
I wouldn't just toss one in a tub just to see what happens. mine for instance won't even soak in his water bowl