# Astronomy Challenge

#### What is a constellation?

In astronomy a constellation is a grouping of stars on the celestial sphere perceived as a figure or design. There are 88 recognized constellations and each of these have been named after characters from classical Greek and Roman mythology as well as various common animals and objects.

#### Python Challenge

In this challenge we are using Python Turtle to draw famous constellations on the screen.

Each constellation is saved as a list. Each value of the list represents a star. Each star is also a list with only 2 values, the x and y coordinates of the star (drawn on a 2D screen). So a constellation is stored as a list of lists!

For instance, for Cassiopeia:

`cassiopeia = [[-90,70],[-50,-10],[0,0],[40,-50],[100,0]]`

Using a for loop we can then read the content of the constellation, to plot each star on the screen, one at a time, based on its x and y coordinates.

#### x,y Coordinates?

The canvas we are drawing on (using Python Turtle) is 400 pixels wide by 400 pixels high.
Look at the canvas below to understand how (x,y) coordinates work:

#### Python Code

Check the following code:

Complete the following code by adding one more constellation of your choice.

You will find the pattern of the most famous constellations on this website.

[pms-restrict display_to=”not_logged_in” message=” “]

#### Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
[/pms-restrict] [pms-restrict subscription_plans=”14217″ message=” “]

#### Solution...

You are viewing this solution as part of your full membership subscription!

Python Code

#### Python Code

```#Astronomy Challenge - www.101computing.net/constellations
import turtle

#Initialise Pythn Turtle and Screen
myPen = turtle.Turtle()
myPen.speed(0)
window = turtle.Screen()
window.bgcolor("#000088")
myPen.color("#FFFFFF")

def drawConstellation(constellation):
#draw the first star
myPen.penup()
myPen.goto(constellation[0])
myPen.begin_fill()
myPen.circle(2)
myPen.end_fill()
myPen.pendown()
#draw each line and star within the constellation
for star in constellation:
myPen.goto(star)
myPen.begin_fill()
myPen.circle(2)
myPen.end_fill()
#hide the turtle
myPen.penup()
myPen.goto(600,600)

#Define Constellations as a list of (x,y) coordinates
plough = [[-140,20],[-60,25],[0,10],[35,-5],[45,-50],[120,-60],[150,-5]]
cassiopeia = [[-90,70],[-50,-10],[0,0],[40,-50],[100,0]]
leo = [[10,30],[50,10],[60,-40],[-90,-50],[-180,-70],[-110,0],[10,30],[15,80],[60,130],[80,120]]
lyra = [[30,75],[-60,73],[-150,1-100],[-50,-110],[30,75],[50,120],[80,90],[30,75]]

#drawConstellation(plough)
#drawConstellation(cassiopeia)
#drawConstellation(leo)
drawConstellation(lyra)
```
[/pms-restrict]

Did you like this challenge?

Click on a star to rate it!

Average rating 4.7 / 5. Vote count: 7

No votes so far! Be the first to rate this post.

As you found this challenge interesting...