Night sky


 

from turtle import *
from random import randint

# page setup
setup(1200, 900)
speed(0)
bgcolor("black")

# function to draw stars
def star():
    color("yellow")
    begin_fill()
    for i in range(5):
        forward(10)
        right(144)
end_fill()

# draw mutiple stars at random locations on the screen
for i in range(50):
    x = randint(-400, 400)
    y = randint(-250, 250)
    star()
    penup()
    goto(x, y)
    pendown()
    
# moon - part 1
penup()
goto(-300, 100)
pendown()
color("white")
begin_fill()
circle(50)
end_fill()

# moon - part 2
penup()
goto(-280, 100)
pendown()
color("black")
begin_fill()
circle(50)
end_fill() 

Comments