Planets Top Trumps

For this challenge we will create a variant of the game of Top Trumps using 9 cards, one for each of planet of our Solar System.

We will store all the cards and data about the planets in a list of lists, equivalent to a two-dimensional array, called planets. The “array” will contain 9 rows (from 0 to 8) and 5 columns (0 to 4) with the following columns/fields:

  • Name of the planet,
  • Distance from the Sun (in million km),
  • Size (Diameter) in km,
  • Orbital Period in days,
  • Number of Moons.

We will then be able to access a single piece of data using indexes as follows:
planets-list-of-list

Game Rules


We will write a python program based on the planets array (list of lists) which:

  1. Randomly picks a planet/card from the deck and display all its data on screen,
  2. Randomly picks a planet for the computer, without displaying it on the screen,
  3. Asks the end-user which criteria to compare for this round: (1-Distance from the Sun, 2-Size, 3-Orbital Period,4-Number of Moons),
  4. Compares both cards using the chosen criteria,
  5. Tells the player whether they won, drew or lost,
  6. Gives the computer or the player points: 3pts for a win, 1pt for a draw,
  7. Displays both the computer and the player’s scores and repeats the whole process until the player or the computer reaches a score of 12 and hence win the game.

Complete The Code


Share Button
Posted in Computer Science, Python - Intermediate, Python Challenges Tagged with:

Our Latest Book