Getting Started
Swipe to show menu
Welcome to the Python Ninja!
In this course, you will learn the Python programming language by playing a game. Instead of writing abstract code, you will control a Ninja inside a small world.
At the beginning, you will start with very simple commands: moving the Ninja around the map, picking up sushi, and placing them in the right spots.
As you progress, the challenges will slowly introduce core programming concepts: functions to reuse actions, loops to repeat steps, and conditions to make decisions.
How to Control the Ninja?
The game provides you with commands that let you control the Ninja. Here is a simple code example to help you understand:
ninja.py
Feel free to click Run Code to see how the code works.
Every time the level starts, the game looks for this block:
def ninja_controller(ninja):
Think of it as the place where you write all the commands for your Ninja. Everything written inside this block is executed from top to bottom:
ninja.go_up()moves the Ninja one tile up on the map;ninja.pick_sushi()picks up the sushi on the tile where the Ninja is standing.
All Ninja commands must be indented inside ninja_controller.
For example, the code below does not work:
def ninja_controller(ninja):
ninja.go_up()
ninja.pick_sushi()
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat