How to play Code Farm
Your duck has a farm, a watering can and fifteen parsnip seeds. There are no arrow keys: everything it does, it does because your Python code says so. Write a script in the editor and press Run (or Ctrl+Enter). The duck acts it out on the farm, and anything you print() shows up in the console.
The lesson card above the editor says what to try next, with an example you can copy. There are 20 lessons, from print() and your first move() through for loops, if, functions, return values, lists, while loops, dicts and importing your own modules. Each one pays you some gold.
The farm
- Crops:
till()grass into soil,plant("parsnip")andwater(). A crop grows one day for every day it’s watered (rain waters everything).harvest()it when it’s ripe. - Seasons: 28 days each. Spring has parsnips, potatoes, green beans and cauliflower; summer tomatoes, blueberries, melons and corn; fall yams, cranberries, pumpkins and corn. Crops wither when their season ends, and nothing grows in winter.
- Money:
ship()things into the shipping bin and you’re paid overnight. - Energy and time: tilling, watering, clearing and fishing use energy.
sleep()ends the day; stay up past 2am and your duck falls asleep where it stands. Your script carries on the next morning. - Water: your can holds 40.
refill()it next to the pond. - Town:
go("town"). Pip’s seed shop is open 9am to 5pm, every day but Wednesday. Talk to Mabel, Gus, Ivy and Rowan and give them gifts they like to make friends. - Fishing: stand next to the pond and
fish(). Rain brings out the catfish. - Sprinklers: buy one,
place("sprinkler")it on grass, and it waters the four tiles beside it every morning.
Tips
- Type
help()in the one-line box under the console for every farm function, orhelp(move)for one. - The one-line box is handy for looking around:
inventory(),tile(),position(). - Make a second script called
helpersfor functions you use a lot, thenfrom helpers import goto. - Speed it up with Fast or Instant once you trust your code. Skip to end jumps to the result.
- x counts from 0 on the left to 15, y from 0 at the top to 10.
Questions
Is this real Python? Yes. It’s Python 3.14 running in your browser (Pyodide), so everything you learn works the same anywhere else. The standard library is there too.
Does my code leave my computer? No. It runs in your browser and nothing is sent anywhere.
Does it save? Your farm and your scripts are saved in this browser after every run.
My code froze. Press Stop. Runs also stop by themselves after 5,000 farm actions or a very long loop, and anything that runs for 20 seconds is stopped without changing your farm.