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
How to write "I love you" in Python
Print "I love you" in Python, repeat it 100 times, and turn it into 143, binary and Morse code. Every example runs in your browser.
Open →Python heart code: draw a heart with turtle or text
Copy-and-run Python heart code: a heart made of stars, a heart filled with LOVE, and red turtle hearts. Change the colours and add a name.
Open →Happy birthday code in Python
Happy birthday in Python: a text cake, the song with a loop, a typing effect, candles for any age, and a countdown to your birthday.
Open →Quick ones to try right now
A secret message, backwards
ruof ta esuoheert eht ta em teeM Meet me at the treehouse at four
Rocket countdown
5 4 3 2 1 Lift off! 🚀
Your name in a box
+----------+ | Python | +----------+
A times-table square
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
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 courseMore free ways to learn
Practice
Free Python practice online: exercises with answers you check in your browser, plus 79 coding games, one for every beginner topic.
Teach
Free resources for teaching Python to kids and beginners: a Scratch to Python guide, printable worksheets with answers, and a game-based course.
Guides
Short guides on learning Python with games, how long it takes, and where to start.