🐍 Python Tutorial
import turtle
import random

screen = turtle.Screen()
screen.setup(400, 500)
screen.bgcolor('#0a0a40')

pen = turtle.Turtle()
pen.hideturtle()
pen.speed(0)

pen.color('white')
for i in range(30):
    star_x = random.randint(-200, 200)
    star_y = random.randint(-250, 250)
    pen.penup()
    pen.goto(star_x, star_y)
    pen.dot(3)

# Draw the rocket at the bottom
rocket_x = 0
rocket_y = -200

pen.penup()
pen.goto(rocket_x, rocket_y)
pen.color('silver')
pen.dot(30)

screen.mainloop()

Project 3 — Step 2 of 4

⭐ Step 2 — Add the rocket

➡️ Draw the rocket at the bottom of the screen.

For now the rocket is just a big silver dot. We’ll make it move in the next step.

✏️ What to type

After the star loop (before screen.mainloop()), add:

rocket_x = 0
rocket_y = -200

pen.penup()
pen.goto(rocket_x, rocket_y)
pen.color('silver')
pen.dot(30)
import turtle
import random

screen = turtle.Screen()
screen.setup(400, 500)
screen.bgcolor('#0a0a40')

pen = turtle.Turtle()
pen.hideturtle()
pen.speed(0)

pen.color('white')
for i in range(30):
    star_x = random.randint(-200, 200)
    star_y = random.randint(-250, 250)
    pen.penup()
    pen.goto(star_x, star_y)
    pen.dot(3)

# Add a silver rocket dot at (0, -200) here

screen.mainloop()

Tap ▶ Run. A silver rocket should appear at the bottom of the starry sky. 🚀

Next → Step 3

⬅ Back to Step 1


Adapted from Raspberry Pi Foundation — Rocket Launch under CC BY-SA 4.0.