You can run Python reasonably well with pythonista or Pyto (I like pythonista, but Pyto supports some PyPI libraries). Apple's Swift playgrounds is pretty decent for Swift. They're all only up to a point, but you can do plenty of actually interesting stuff with them. I use them on my current iPad (and run the Python scripts on my phone).
But 4th gen is old, so it's quite possible none of that works. Maybe web stuff with something like Textastic if you pay for shared hosting somewhere, or a low end VPS isn't crazy expensive and lets you run code. If it's consistent power that's your concern, raspberry pis can be paired with one of those portable USB batteries if it can be charged and send charge at the same time.
If those options are still too expensive, really no clue. It's hard with no money at all.