Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions de-DE/code/starter/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from p5 import *
from math import sin

x = 0 # starting position of the snake


def setup():
size(400, 400)
background('lightblue')
no_stroke()


def draw():

run()
4 changes: 4 additions & 0 deletions de-DE/code/starter/project_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: "Python wild - Wiggle the snake"
identifier: "python-wild-wiggle-the-snake"
type: 'python'
build: true
Binary file added de-DE/images/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added de-DE/images/step_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added de-DE/images/step_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added de-DE/images/step_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added de-DE/images/step_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added de-DE/images/step_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added de-DE/images/step_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions de-DE/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
title: "Python wild - Wiggle the snake"
hero_image: images/banner.png
description: Make a colourful snake slither across the screen using variables and animation in Python.
meta_title: Learn to code with Python Wild | Wiggly Snake
meta_description: Learn Python with the Raspberry Pi Foundation. Build and animate a wiggly snake with code and creativity.
version: 1
listed: true
copyedit: false
last_tested: "2025-04-10"
steps:
- title: step_1
- title: step_2
completion:
- engaged
- title: step_3
- title: step_4
- title: step_5
- title: step_6
completion:
- internal
- external
87 changes: 87 additions & 0 deletions de-DE/resources/dataframe.json

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions de-DE/resources/mentor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Mentor Notes: Wiggle the snake

## Project Overview

In this Python Wild project, learners use the p5 library to build and animate a wiggly cartoon snake. They start by drawing shapes, then bring the snake to life using animation based on variables and sine waves.

---

## What Learners Will Practise

- Drawing with `circle()`
- Using variables for animation
- Coordinating movement with `x` and `offset`
- Layering and positioning shapes
- Customising with colour and expression

---

## Teaching Tips

- Highlight that `draw()` repeats automatically, like a flipbook
- Keep explanations of `sin()` simple — focus on the effect, not the math
- Let learners experiment with speed, size, and colour freely

---

## Extension Ideas

- Add a tongue or crown
- Animate other creatures (e.g. caterpillar or dragon)
- Add a background or sound effects
33 changes: 33 additions & 0 deletions de-DE/solutions/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from p5 import *
from math import sin

x = 0 # starting position of the snake

def setup():
size(400, 400)
background('lightblue')
no_stroke()

def draw():
global x
background('lightblue')
fill('green')

offset = sin(x * 0.1) * 10

circle(x, 200, 50) # head at x
circle(x - 35, 200 + offset, 40) # body 1
circle(x - 65, 200 - offset, 35) # body 2
circle(x - 90, 200 + offset, 30) # tail

fill('white')
circle(x + 10, 190, 10)
circle(x + 25, 190, 10)

fill('black')
circle(x + 10, 190, 5)
circle(x + 25, 190, 5)

x += 2

run()
65 changes: 65 additions & 0 deletions de-DE/step_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<h2 class="c-project-heading--task">Draw the snake's head</h2>

\--- task ---

Draw a green circle in the middle of the screen to make your snake's head.

\--- /task ---

<h2 class="c-project-heading--explainer">Hello, snake!</h2>

In this project, you’ll create a slithering animated snake using Python and p5.
Start by drawing a green circle for the snake’s head.

<div class="c-project-code">
--- code ---
---
language: python
filename: main.py
line_numbers: true
line_number_start: 1
line_highlights: 14, 15
---

from p5 import \*
from math import sin

x = 0 # starting position of the snake

def setup():
size(400, 400)
background('lightblue')
no_stroke()

def draw():
fill('green')
circle(200, 200, 50)

run()

\--- /code ---

</div>

<div class="c-project-output">
![A single green circle on a light blue background](images/step_1.png)
</div>

<div class="c-project-callout c-project-callout--tip">

### Tip

Try changing the size of the circle or the colour.

</div>

<div class="c-project-callout c-project-callout--debug">

### Debugging

If you don’t see anything:<br />

- Make sure the `circle()` has **three numbers**: x, y, and size<br />
- Run your code again after saving

</div>
61 changes: 61 additions & 0 deletions de-DE/step_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<h2 class="c-project-heading--task">Add a body segment</h2>

\--- task ---

Draw a second green circle behind the snake’s head to make part of its body.

\--- /task ---

<h2 class="c-project-heading--explainer">Stretching out</h2>

Add a second circle behind the head. This will start to make the snake look longer.

You’ll need to:

- Use another `circle()`
- Make it slightly smaller than the head
- Move it a little to the left

<div class="c-project-code">
--- code ---
---
language: python
filename: main.py
line_numbers: true
line_number_start: 13
line_highlights: 16
---

def draw():
fill('green')
circle(200, 200, 50)
circle(165, 200, 40)

run()

\--- /code ---

</div>

<div class="c-project-output">
![Two green circles, one smaller and behind the other, on a light blue background](images/step_2.png)
</div>

<div class="c-project-callout c-project-callout--tip">

### Tip

Try changing the second circle’s position or size to see how it changes the snake’s body shape.

</div>

<div class="c-project-callout c-project-callout--debug">

### Debugging

If the body doesn’t show up:<br />

- Are the numbers for the two circles different to each other?<br />
- Make sure you clicked run

</div>
64 changes: 64 additions & 0 deletions de-DE/step_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<h2 class="c-project-heading--task">Make the snake move</h2>

\--- task ---

Use a variable to make your snake slither across the screen.

\--- /task ---

<h2 class="c-project-heading--explainer">It’s alive!</h2>

You’re about to make your snake move across the screen.

Use a variable called `x` to keep track of where the snake's head is.
Each time `draw()` runs, we’ll add a little to `x` to move everything to the right.

The `draw()` function runs many times per second. That’s why we draw the background each time — it clears the screen so the snake doesn’t leave a trail.

<div class="c-project-code">
--- code ---
---
language: python
filename: main.py
line_numbers: true
line_number_start: 13
line_highlights: 15, 17-18, 20
---

def draw():
global x
background('lightblue')
fill('green')
circle(x, 200, 50) # head at x
circle(x - 35, 200, 40) # body at x - 35

```
x += 2 # increase x by 2
```

\--- /code ---

</div>

<div class="c-project-output">
![The head and body of the snake moving to the right](images/step_3.png)
</div>

<div class="c-project-callout c-project-callout--tip">

### Tip

Try changing how fast the snake moves by using a bigger or smaller number in `x += 2`.

</div>

<div class="c-project-callout c-project-callout--debug">

### Debugging

If the snake doesn’t move:<br />

- Did you use `global x` inside `draw()`?<br />
- Are you updating `x` with `x += 2`?

</div>
69 changes: 69 additions & 0 deletions de-DE/step_4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<h2 class="c-project-heading--task">Make the snake longer</h2>

\--- task ---

Add two more circles behind the snake to make its full body.

\--- /task ---

<h2 class="c-project-heading--explainer">Slither, slither...</h2>

Give your snake a longer body by adding two more segments behind it.

Keep using the `x` variable and subtract different amounts to place each circle in the right spot.

Each one should be a little smaller, and moved further to the left.

<div class="c-project-code">
--- code ---
---
language: python
filename: main.py
line_numbers: true
line_number_start: 13
line_highlights: 19-20
---

def draw():
global x
background('lightblue')
fill('green')
circle(x, 200, 50) # head at x
circle(x - 35, 200, 40) # body 1
circle(x - 65, 200, 35) # body 2
circle(x - 90, 200, 30) # tail

```
x += 2 # increase x by 2
```

run()

\--- /code ---

</div>

<div class="c-project-output">
![A full snake made from 4 green circles of different sizes](images/step_4.png)
</div>

<div class="c-project-callout c-project-callout--tip">

### Tip

- Try changing the sizes of the circles to make a chunky or skinny snake.<br />
- You can also change how far apart the segments are.

</div>

<div class="c-project-callout c-project-callout--debug">

### Debugging

If some parts of the body don’t show up:<br />

- Check each `circle()` has 3 numbers<br />
- Look out for spelling errors or missing commas<br />
- Remember: every new segment is further left (use `x - ...`)

</div>
Loading