Fun Python code to copy and run

Short Python programs that are fun to run and easy to change. Each one runs right here in your browser, with nothing to install. Press Run, then change a word or a number and see what happens.

Fun Python code to try

Quick ones to try right now

A secret message, backwards

main.py
Output
ruof ta esuoheert eht ta em teeM
Meet me at the treehouse at four

Rocket countdown

main.py
Output
5
4
3
2
1
Lift off! 🚀

Your name in a box

main.py
Output
+----------+
|  Python  |
+----------+

A times-table square

main.py
Output
   1   2   3   4   5
   2   4   6   8  10
   3   6   9  12  15
   4   8  12  16  20
   5  10  15  20  25

A random compliment

main.py
Output
You learn fast!

Every program on this page uses an idea from the course: printing, loops, text tools and lists. If you'd like to learn them properly, one game at a time, start with the free games.

Questions people ask

What are some cool Python codes to run?

Good first ones are a heart made of stars, "I love you" in binary, a rocket countdown with time.sleep(), a secret message read backwards with [::-1], and a times-table square made with two loops.

Can I run this Python code without installing anything?

Yes. Every example on these pages runs in your browser with real Python. Press Run, and the output appears under the code.

Can I copy the code into my own Python?

Yes. Press Copy, paste it into a .py file or IDLE, and run it. The turtle examples open a drawing window on your computer.

Learn Python with games

Every idea on this page has its own game in the course, with a short video and six levels. The three games in Module 1 are free: no account, nothing to install.

Every idea on this page has its own game in the course. Pick up where you left off.

Play the first game freeContinue the course