Does the Python code you want to run use PyTorch? Is it related to LLMs or Stable Diffusion? Because those should also run on CPU alone. Not very fast, but good enough to play around with.
If you're thinking of renting a machine from AWS, I'm currently using a "g4dn.xlarge" instance which does support CUDA and can run Stable Diffusion comfortably. It's a bit pricey though and I had to wait and get approved before I could rent it.
A good LLM build maximizes the amount of VRAM you're getting for AI workloads. Shop around for a 3090 24gb if that's within your price range, and then build backwards from there. Cheaper options include the 3060 12gb and the various other 16-20gb CUDA-enabled cards. Then find a motherboard that maxes out your card's PCI bandwidth and select a budget CPU that fits the socket and won't bottleneck your GPU. Add your memory, storage and install an OS. Then you're done.
If you still insist on paying next-gen prices for last-gen hardware, Lenovo and Dell have you covered:
https://www.lenovo.com/us/en/p/workstations/thinkstation-p-s...
https://www.dell.com/en-us/shop/scc/sr/workstations/precisio...